Skip to content

Instantly share code, notes, and snippets.

View ajstewartlang's full-sized avatar

Andrew Stewart ajstewartlang

View GitHub Profile
library(tidyverse)
library(gganimate)
data <- NULL
sample <- NULL
d <- NULL
for (i in (1:100)) {
set.seed(i+1234)
a <- rnorm(25, 1000, 50)
@ajstewartlang
ajstewartlang / gist:c6eca4722071b318b376af13aab26c2b
Last active July 24, 2018 12:14
animating tweets using rtweet and tidytext for extraction/tidying and gganimate for animation
#Slightly messy code - could easily be improved upon
#new version of gganimate not yet on CRAN so need to download from github with devtools package
#devtools::install_github('thomasp85/gganimate')
library(tidytext)
library(tidyverse)
library(rtweet)
library(gganimate)
library(lubridate)
@ajstewartlang
ajstewartlang / gist:89dcdf01c4512a213141a16e9243626d
Last active November 24, 2023 21:15
Hacked together code for animated raincloud plots for N=20 and N=500 where no difference exists in underlying populations
# Usimg @micahgallen's nice raincloud plot code
# https://wellcomeopenresearch.org/articles/4-63
# and fork of benmarwick/geom_flat_violin.R code
# gganimate by Thomas Lin Pedersen - @thomasp85
devtools::install_github('thomasp85/gganimate')
library(tidyverse)
library(gganimate)
library(RColorBrewer)
@ajstewartlang
ajstewartlang / gist:33b396ae9e9c344639dfcd431cc268d2
Created July 19, 2018 20:19
Animated violin plots for two sample sizes where no real effect exists
devtools::install_github('thomasp85/gganimate')
library(tidyverse)
library(gganimate)
#plotting two groups when no difference exists
df <- NULL
set.seed(1111)
sample_size=20
# somewhat hackish solution to:
# https://twitter.com/EamonCaddigan/status/646759751242620928
# based mostly on copy/pasting from ggplot2 geom_violin source:
# https://github.com/hadley/ggplot2/blob/master/R/geom-violin.r
library(ggplot2)
library(dplyr)
"%||%" <- function(a, b) {