Hello,
I am trying to generate very simple general descriptive statistics on how children rated the taste of a drink. Responses on the survey question range from 0 to 10 but it is getting complicated because each child answered a different number of surveys across the course of a week long period.
For each participant, I would like to get the percentage of times they used response (e.g. 1: 10%, 2: 0%, 3:20%, etc).
I was thinking along these lines but something that actually works!
group_by(subject_id) %>%
summarize(endorse_10 = count(SUGARY_DRINK_TASTE == 10)/length())
Can anyone advise?
For a sample of my dataset please see below:
taste <- structure(list(subject_id = c(28053, 28053, 28053, 28053, 28053,
28054, 28054, 28054, 28056, 28056, 28056, 28056, 28056, 28056,
28056, 28056, 28056, 28057, 28057, 28057, 28057, 28057, 28057,
28057, 28057, 28057, 28057, 28057, 28057, 28057, 28057, 28057,
28057, 28057, 28057, 28058, 28058, 28058, 28058, 28058, 28058,
28058, 28058, 28058, 28058, 28058, 28058, 28058, 28058, 28058
), SUGARY_DRINK_TASTE = c(10, 0, 10, 10, 10, 9, 10, 1, 9, 10,
10, 6, 10, 8, 10, 10, 4, 8, 7, 8, 7, 8, 9, 9, 9, 9, 7, 10, 10,
0, 7, 8, 7, 10, 8, 5, 10, 8, 8, 10, 10, 10, 10, 6, 7, 10, 10,
6, 10, 10)), class = c("grouped_df", "tbl_df", "tbl", "data.frame"
), row.names = c(NA, -50L), groups = structure(list(subject_id = c(28053,
28054, 28056, 28057, 28058), .rows = structure(list(1:5, 6:8,
9:17, 18:35, 36:50), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), class = c("tbl_df", "tbl", "data.frame"
), row.names = c(NA, -5L), .drop = TRUE))