Created
March 24, 2020 23:29
-
-
Save Tadge-Analytics/3613067bc9c703c580cdbfbab8390846 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
library(tidyverse) | |
# let's start with some familiar data | |
# Why are you doing this workshop? | |
# Please rank your top 3 | |
responses <- c( | |
"To improve my job prospects", | |
"To gain life experiences", | |
"Thirst for knowledge and learning", | |
"To be challenged intellectually", | |
"I am ambitious and want to advance my career", | |
"To increase earning potential (salary)", | |
"For a career change") | |
n_rankings <- 3 | |
n_respondents <- 50 | |
set.seed(123) | |
responses_data <- | |
tibble(respondent_id = 1:n_respondents) %>% | |
mutate(gender = sample(c("M", "F"), n(), replace = T), # for a table later on.../ | |
selections = map(respondent_id, ~sample(responses, n_rankings))) %>% | |
unnest(selections) %>% | |
group_by(respondent_id) %>% | |
mutate(selection_rank = row_number()) %>% | |
ungroup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment