split_df | R Documentation |
This function is the first part of the split-apply-combine workflow in handling multiple selection questions in the survey. In multi-select, participants are able to choose from a menu of choices provided. From a data perspective, multi-select responses are recorded in wide format where each column represents a single choice in a multi-select question. Related columns, i.e., those belonging to the same multi-select question, are grouped together using homogeneous "prefixes." This function takes a single data frame, divides it into subsets based on patterns in the column names (the "prefixes"), and returns a list containing the subsets.
split_df(df, patterns, weight)
df |
A data frame or data.table or tibble. |
patterns |
A character vector of "prefixes" for selecting columns in |
weight |
A single string of the weighting variable. |
A list of data frames, each of which is a data.table
object.
apply_topline_multiselect()
for vectorized topline generation for multiple selection questions and
combine_topline_multiselect()
for combining the multiselect toplines.
# Vector of patterns patterns <- c("prefix_1", "predix_2", ...) # List of data.tables list_df <- split_df(df, patterns, "weight_var")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.