This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
devtools::install_github('thomasp85/gganimate') | |
library(tidyverse) | |
library(gganimate) | |
#plotting two groups when no difference exists | |
df <- NULL | |
set.seed(1111) | |
sample_size=20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gganimate) | |
data <- NULL | |
sample <- NULL | |
d <- NULL | |
for (i in (1:100)) { | |
set.seed(i+1234) | |
a <- rnorm(25, 1000, 50) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note, this uses the new version of gganimate by Thomas Lin Pedersen (@thomasp85) available from: | |
# https://github.com/thomasp85/gganimate | |
# Apologies for clunkiness of code below... | |
library(tidyverse) | |
library(gganimate) | |
data <- NULL | |
sample <- NULL | |
d <- NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Written by Victor Yu (@VictorYuEpi) | |
## From https://pastebin.com/44c6GsDM | |
## playing around with some sports data - tracking the rank of athletes who completed the decathlon at the 2016 Rio Olympics #r #ggplot2 #gganimate #dataviz #Datavisualization | |
## install/load required packages #### | |
library(tidyverse) | |
library(RColorBrewer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
df <- NULL | |
set.seed(1111) | |
sample_size = 20 | |
for (i in 1:100000) { | |
a <- rnorm(sample_size, mean = 10, sd = 2) | |
b <- rnorm(sample_size, mean = 10, sd = 2) | |
a <- cbind(a, rep ("A", sample_size), rep (i, sample_size)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note this uses the new version of gganimate by Thomas Lin Pedersen - @thomasp85 | |
# it is not yet on CRAN so need to use devtools to install it | |
# devtools::install_github('thomasp85/gganimate') | |
library(gganimate) # New version of gganimate | |
library(tidyverse) # All praise the tidyverse | |
library(MASS) # Needed to sample from multivariate distribution | |
# Simulating multivariate data with specific covariance structure | |
# Use the mvrnorm() function from the MASS package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From @nnstats on Twitter | |
# Imagine a hockey game where we know that Team A scores exactly 1 goal for sure and Team B takes 20 shots, | |
# each with a 5.5% chance of going in. | |
# Which team would you rather be? | |
# (nothing additional happens if you tie.) | |
library(tidyverse) | |
library(gganimate) | |
set.seed(1234) |
OlderNewer