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
--- | |
title: "Visualizing Data (in R)" | |
subtitle: "An opinionated style guide" | |
author: "<br><br>June Choe<br><br>Phonetics Lab" | |
date: '2020-10-23' | |
output: | |
xaringan::moon_reader: | |
lib_dir: libs | |
css: [default, hygge, ninjutsu] | |
nature: |
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
read_csv("https://yjunechoe.netlify.app/data/CarvalhoEtAl_2017.csv", col_types = cols(reveal_time = col_integer())) %>% | |
ggplot(aes(Time, Proportion)) + | |
geom_ribbon( | |
aes(ymin = YMin, ymax = YMax, group = Condition), | |
color = "grey70", | |
fill = "grey80", | |
alpha = .3 | |
) + | |
geom_point( | |
aes(color = Condition, group = Condition) |
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) | |
library(rlang) | |
split_track <- function(df, grouping_var, tracked_along, ..., tracked_groups = ".all") { | |
region <- df %>% | |
filter(...) %>% | |
group_by({{ grouping_var }}) %>% | |
mutate(row_id = 1:n()) %>% |
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
# https://pbs.twimg.com/media/Ek8VZFEVgAAHZM_?format=png&name=4096x4096 | |
colortweets <- rtweet::get_timeline("everycolorbot", 1000) | |
colortweets_df <- colortweets %>% | |
select(created_at, text, favorite_count) %>% | |
mutate( | |
hour = lubridate::hour(created_at), | |
hex = paste0("#", str_extract(text, "(?<=0x).*(?= )")) | |
) |
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(slider) | |
library(gganimate) | |
points <- tibble( | |
id = 1:100, | |
x = runif(100), | |
y = runif(100), | |
time = 1:100, | |
size = 2, |
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(patchwork) | |
library(magick) | |
df <- tribble( | |
~Condition, ~Referent, ~Accuracy, | |
"Primacy", "Single", 0.63, | |
"Primacy", "Primacy", 0.59, | |
"Recency", "Single", 0.63, | |
"Recency", "Recency", 0.5, |
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
## Code by Walker Harrison @walkwearscrocs | |
## From https://www.walker-harrison.com/posts/2021-02-13-visualizing-how-a-kernel-draws-a-smooth-line/ | |
library(tidyverse) | |
theme_set(theme_bw()) | |
set.seed(0) | |
n <- 100 | |
x <- runif(n, 0, 4*pi) |
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(dplyr) | |
library(ggplot2) | |
library(gganimate) | |
# Path to Font Awesome 5 Brands ttf file | |
fa_brands <- paste0( | |
Sys.getenv("FONT_PATH"), | |
"Font-Awesome-5-Brands-Regular-400.ttf" | |
) |
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(ggplot2) | |
library(ggfx) | |
library(ragg) | |
ggplot(NULL) + | |
as_reference( | |
geom_rect( | |
aes(xmin = -1, xmax = 1, ymin = -.6, ymax = -.6 + 1.2 * (8/60)), | |
fill = '#961A1F', | |
), |
OlderNewer