View source: R/apply_topline_multiselect.R
apply_topline_multiselect | R Documentation |
This function is the second part of the split-apply-combine workflow in handling multiple selection questions
in the survey. It takes the result of split_df()
. The caption
argument can also be generated with the helper function.
apply_topline_multiselect(list_df, weight, caption, parent)
list_df |
A list of data frame objects. |
weight |
A single string of the weighting variable. |
caption |
A list of character vectors of captions for the toplines. |
parent |
A logical vector of booleans indicating whether |
A list containing two elements— result
and error
, which are lists in and of themselves.
These two lists have the same structure and number of elements. The result
is a list
of list objects. One can think of each element in result
as the output of a single run of
generate_topline_multiselect()
, if it suceeds. The error
list captures all runs of
generate_topline_multiselect()
that have failed, returning the error messages. If all run fails,
result
will be a NULL
list; on the other end, if no run fails, error
will be a NULL
list.
generate_topline_multiselect()
for single topline generation for multiple selection questions,
split_df()
for splitting a single data frame into smaller subsets, 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") # Apply topline generation to each element of 'list_df' captions <- list(c("caption_parent", "caption_child"), "caption_2", ...) parents <- c(TRUE, FALSE, ...) results <- apply_topline_multiselect(list_df, "weight_var", captions, parents)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.