Skip to content

Instantly share code, notes, and snippets.

@darokun
Created March 11, 2021 17:34
Show Gist options
  • Save darokun/ad0f893985427bf85f832c5ed15e5819 to your computer and use it in GitHub Desktop.
Save darokun/ad0f893985427bf85f832c5ed15e5819 to your computer and use it in GitHub Desktop.
# data from http://www.edisonresearch.com/wp-content/uploads/2017/04/Podcast-Consumer-2017.pdf
library(tidyverse)
set.seed(20210311)
podcast_women <- tibble(
gender = rep("female", 2000*.44),
y2013 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.09, 1 - 0.09)),
y2014 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.13, 1 - 0.13)),
y2015 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.16, 1 - 0.16)),
y2016 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.18, 1 - 0.18)),
y2017 = sample(c("yes", "no"), size = 2000*.44, replace = TRUE, prob = c(0.21, 1 - 0.21))
)
set.seed(20210311)
podcast_men <- tibble(
gender = rep("male", 2000*.56),
y2013 = sample(c("yes", "no"), size = 2000*.56, replace = TRUE, prob = c(0.15, 1 - 0.15)),
y2014 = sample(c("yes", "no"), size = 2000*.56, replace = TRUE, prob = c(0.17, 1 - 0.17)),
y2015 = sample(c("yes", "no"), size = 2000*.56, replace = TRUE, prob = c(0.17, 1 - 0.17)),
y2016 = sample(c("yes", "no"), size = 2000*.56, replace = TRUE, prob = c(0.24, 1 - 0.24)),
y2017 = sample(c("yes", "no"), size = 2000*.56, replace = TRUE, prob = c(0.27, 1 - 0.27))
)
podcast_gender <- bind_rows(podcast_women, podcast_men)
podcast_gender %>%
tableone::CreateTableOne(
vars = as.character(names(podcast_gender))[-1],
strata = "gender",
factorVars = as.character(names(podcast_gender))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment