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(janitor) | |
library(countrycode) | |
library(ggthemes) | |
waste_vs_gdp <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-05-21/per-capita-plastic-waste-vs-gdp-per-capita.csv") | |
waste_vs_gdp <- clean_names(waste_vs_gdp) | |
waste_vs_gdp$continent <- countrycode(sourcevar = waste_vs_gdp$entity, |
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(janitor) | |
library(countrycode) | |
library(ggthemes) | |
coast_vs_waste <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-05-21/coastal-population-vs-mismanaged-plastic.csv") | |
coast_vs_waste <- clean_names(coast_vs_waste) | |
coast_vs_waste$continent <- countrycode(sourcevar = coast_vs_waste$entity, |
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
# pkgs | |
pacman::p_load(tidyverse, polite, scales, ggimage, ggforce, | |
rvest, glue, extrafont, ggrepel, magick) | |
loadfonts() | |
## add_logo function from Thomas Mock | |
add_logo <- function(plot_path, logo_path, logo_position, logo_scale = 10){ | |
# Requires magick R Package https://github.com/ropensci/magick |
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(ggthemes) | |
library(tools) | |
library(gganimate) | |
library(ggimage) | |
full_trains <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-02-26/full_trains.csv") | |
p <- full_trains %>% | |
filter(service == "International" & year == 2017) %>% |
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(broom) | |
library(Hmisc) | |
total_samples <- 10000 | |
sample_size <- 128 | |
participant <- rep(1:sample_size) | |
condition <- c(rep("fast", times = sample_size/2), rep("slow", times = sample_size/2)) | |
all_data <- 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
# 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) |
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
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
## 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
# 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 |