generate_topline_multiselect: Generate toplines for multiple selection questions

View source: R/generate_topline_multiselect.R

generate_topline_multiselectR Documentation

Generate toplines for multiple selection questions

Description

This function generates a single topline for cases where there is no parent response column in the multiselect question. These cases are organized such that each column in df represents a single choice in a multiselect question. Alternatively, there may be cases where df is structured such that the first column represents a parent of the multiselect question in addition to the choices or children columns that represent the multiselect choices. In such cases, two toplines will be generated— one for the parent response and another for the choices columns. Users may control the output with the parent argument. Note that, for multiselect questions that involve a parent response column, it is assumed that such a column is the first column of the argument df. Therefore, some pre-processing may be needed to ensure that this requirement is met.

Usage

generate_topline_multiselect(df, weight, caption, parent = FALSE)

Arguments

df

A data frame or data.table or tibble.

weight

A single string of the weighting variable.

caption

A length one character vector used as the caption for the topline.

parent

A boolean indicating whether df has a parent response column. Defaults to FALSE.

Value

A list object containing a either one or two objects of class flextable.

See Also

apply_topline_multiselect() for vectorized topline generation for multiple selection questions.

Examples


# Generate a topline (multiselect)
df %>%
  generate_topline_multiselect(
    df = .,
    "weight",
    "caption",
    FALSE
  )


YangWu1227/citizenr documentation built on June 18, 2022, 12:17 p.m.