Skip to contents

Count the number of unique responses to "Select All" Questions

Usage

select_all(data, group_var = NULL, column_prefix)

Arguments

data

A data frame, typically from a Qualtrics Survey, where responses to 'select all' questions are provided in consecutive columns prefixed with the question number and underscore, with a number corresponding to each response option.

group_var

Column name for aggregrating variable of interest if the results should the results be grouped by another variable.

column_prefix

Question number and underscore

Value

Either a dataframe or a flextable object

Examples

test_df <-
  dplyr::tribble(
    ~Q4, ~Q15_1, ~Q15_2, ~Q15_3, ~Q15_4,
    "Community", NA, NA, NA, NA,
    "Academic", NA, "TREKS", NA, NA,
    "Academic", NA, NA, "Lipps Fellowship", NA,
    "Community", "STARS", NA, NA, "Campbell Fellows",
    "Academic", "STARS", NA, NA, "Campbell Fellows",
    "Community", NA, "TREKS", NA, NA
   ) |>
  dplyr::mutate(
    dplyr::across(dplyr::everything(), as.factor)
)
select_all(
  data = test_df,
  group_var = Q4,
  column_prefix = "Q15"
)
#> Error in list2(...): object 'Q4' not found