Created
October 3, 2019 02:53
-
-
Save jnaecker/ccf251df6000dd32d361ceb9bbe2c63f to your computer and use it in GitHub Desktop.
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
# reference: https://gist.github.com/andrewheiss/51f60fc2a410ca0d321d942153b955e7 | |
library(tidyverse) | |
library(wakefield) # For fancy data generation | |
library(truncnorm) # Truncated normal distributions | |
library(ggridges) # Ridge plots | |
# Make all the random draws consistent | |
set.seed(1234) | |
# Function to generate GPAs | |
gpa_centered_on <- function(mean){ | |
round(rtruncnorm(1, a = 1.0, b = 4.0, mean = mean, sd = .5), 2) | |
} | |
# Generate fake data | |
all_students <- | |
r_data_frame(n = 1600, | |
id, | |
race, | |
age(x = 20:30), | |
gender_inclusive) %>% | |
mutate(undergrad_gpa = gpa_centered_on(2.5), | |
math_camp = c(rep(T, 800), rep(F, 800)), | |
graduate_gpa = gpa_centered_on(3.0 + 0.5*math_camp)) | |
ggplot(all_students, aes(x = graduate_gpa, y = math_camp, fill = math_camp)) + | |
geom_density_ridges() + | |
guides(fill = FALSE) + | |
theme_bw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment