View source: R/question_types.R
load_question_types | R Documentation |
#' Multiple Answer questions #' #' Questions where there are checkboxes, and participants can answer multiple answers #' #' #' @param q_name The column name of the attention check question #' @param levels What the different options should be called #' @param options What the options look like in the original data. NULL == autodetect #' #' @export multiple_answer_question <- function(q_name, levels, options=NULL) if (exists(q_name, envir=mulanswer_questions)) warning(paste0(q_name, " is already a multiple answer question. Overwriting...")) assign(q_name, list(levels=levels, options=options), envir=mulanswer_questions)
load_question_types()
is_multiple_answer_question <- function(column) known_qs <- ls(envir=mulanswer_questions) return(attr(column, "name")
process_multiple_answer_question <- function(column) q_info <- get(attr(column, "name"), envir=mulanswer_questions) out <- stringr::str_split(column, ",") # I have to use an if statement here because factor uses missing() to detect the present of the levels argument # if (!is.null(q_info$options)) # out <- factor(column, levels=q_info$options, labels=q_info$levels) # else # out <- factor(column, labels=q_info$levels) # return(out)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.