Skip to content

Instantly share code, notes, and snippets.

View systats's full-sized avatar

Simon Roth systats

  • University of Konstanz
  • Konstanz/Stuttgart
View GitHub Profile
@cszang
cszang / spawn_progressbar.R
Last active February 14, 2023 13:31
A progressbar that fits into a dplyr::mutate -> purrr::map* pipeline
library(rlang)
library(tidyr)
library(dplyr)
library(purrr)
spawn_progressbar <- function(x, .name = .pb, .times = 1) {
.name <- substitute(.name)
n <- nrow(x) * .times
eval(substitute(.name <<- dplyr::progress_estimated(n)))
x
@HanjoStudy
HanjoStudy / RSelenium.R
Last active November 10, 2023 02:15
useR2018
##########################################################
#
# HANJO ODENDAAL
# hanjo.oden@gmail.com
# www.daeconomist.com
# @UbuntR314
# https://github.com/HanjoStudy
#
#
# ██████╗ ███████╗███████╗██╗ ███████╗███╗ ██╗██╗██╗ ██╗███╗ ███╗
@jasdumas
jasdumas / install_gganimate.md
Last active August 11, 2017 20:11
Getting gganimate to work on Mac
  1. visit for intructions for other OS: https://www.imagemagick.org/script/download.php
  2. download: ImageMagick-x86_64-apple-darwin16.4.0.tar.gz from download button
  3. create (or choose) a directory to install the package into and change to that directory:

cd Desktop/R-directory

mkdir ImageMagick

cd ImageMagick/

@Scub3d
Scub3d / api-lolesports-com_docs.md
Last active March 4, 2020 19:49 — forked from brcooley/api-lolesports-com_docs.md
lolesports.com unofficial api docs
@andrie
andrie / interpolate.R
Last active December 9, 2019 06:56
Interpolation and smoothing functions in R
# Generate data in the form of a sine wave
set.seed(1)
n <- 1e3
dat <- data.frame(
x = 1:n,
y = sin(seq(0, 5*pi, length.out = n)) + rnorm(n=n, mean = 0, sd=0.1)
)
approxData <- data.frame(
@bryangoodrich
bryangoodrich / TwitterTopics.r
Last active September 18, 2024 20:43
Twitter Topic Modeling Using R
# Twitter Topic Modeling Using R
# Author: Bryan Goodrich
# Date Created: February 13, 2015
# Last Modified: April 3, 2015
#
# Use twitteR API to query Twitter, parse the search result, and
# perform a series of topic models for identifying potentially
# useful topics from your query content. This has applications for
# social media, research, or general curiosity
#
@yihui
yihui / htmltools-deps.Rmd
Created March 31, 2015 02:33
A minimal example of HTML dependencies
---
title: HTML Dependencies
output: html_document
---
This example explains how HTML dependencies work in **htmltools**. Sometimes an HTML fragment may have additional dependencies to work correctly, such as JavaScript and/or CSS files. In R Markdown documents, you have to let **rmarkdown** know these dependencies, so they can be added to the HTML header when the document is rendered through Pandoc.
Another thing that you need to pay attention is you have to "protect" your HTML output so that Pandoc does not touch it, e.g. when you have four leading spaces, Pandoc may think this line is supposed to be a `<pre>` block whereas you only meant to indent the line for cosmetic purposes. In this case, the function `htmltools::htmlPreserve()` will be _automatically_ applied to your HTML content in R Markdown if the content is generated from `htmltools::tags` or wrapped in `htmltools::HTML()`.
Now we use a random CSS file in the **knitr** package to illustrate how dependencies work. The goal here is to generate a
@ramhiser
ramhiser / random-forest.r
Created October 22, 2014 21:57
Plots Variable Importance from Random Forest in R
library(randomForest)
library(dplyr)
library(ggplot2)
set.seed(42)
rf_out <- randomForest(Species ~ ., data=iris)
# Extracts variable importance (Mean Decrease in Gini Index)
# Sorts by variable importance and relevels factors to match ordering
@i000313
i000313 / eloRating.R
Last active January 2, 2022 14:37
Elo rating system implementation in R. #elorating #playerskills #ranking
###############################################################################
# Elo rating system implementation in R #
###############################################################################
#
# INTRODUCTION
# The ELO rating system is a method for calculating the relative skill levels
# of players in Player-Versus-Player games. This rating system is used on
# chess and also in a number of games, videogames, etc.
# It was originally invented as an improved chess rating system in the 1960s
# and established at the FIDE-congress 1970 in Siegen (Germany).
@trestletech
trestletech / server.R
Last active October 3, 2025 05:03
A Shiny app combining the use of dplyr and SQLite. The goal is to demonstrate a full-fledged, database-backed user authorization framework in Shiny.
library(shiny)
library(dplyr)
library(lubridate)
# Load libraries and functions needed to create SQLite databases.
library(RSQLite)
library(RSQLite.extfuns)
saveSQLite <- function(data, name){
path <- dplyr:::db_location(filename=paste0(name, ".sqlite"))