Skip to content

Instantly share code, notes, and snippets.

@z3tt
Created June 14, 2021 10:28
Show Gist options
  • Save z3tt/59bff28954fc92287ad954d72a6861b0 to your computer and use it in GitHub Desktop.
Save z3tt/59bff28954fc92287ad954d72a6861b0 to your computer and use it in GitHub Desktop.
Data for Raincloud Plots
set.seed(2021)
data <- tibble(
group = factor(c(rep("Group 1", 100), rep("Group 2", 250), rep("Group 3", 25))),
value = c(
## Group 1
seq(0, 20, length.out = 100),
## Group 2
c(rep(0, 5), rnorm(30, 2, .1), rnorm(90, 5.4, .1), rnorm(90, 14.6, .1), rnorm(30, 18, .1), rep(20, 5)),
## Group 3
rep(seq(0, 20, length.out = 5), 5))
) %>%
rowwise() %>%
mutate(value = if_else(group == "Group 2", value + rnorm(1, 0, .4), value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment