
Apply tab_grid() to multiple grid questions
Source: R/02_06_tabulation_tab_grid_all.R
tab_grid_all.RdThis function maps tab_grid() across all grid question prefixes in a data frame.
Additional arguments are passed to tab_grid().
Grid questions are detected automatically by prefixes before the first underscore (
_).Multiple response (pick-any) sets are skipped, since those should be handled with
tab_mr().
Arguments
- data
A data frame containing the survey data.
- weight
(Optional) A numeric weighting variable. If
NULL(default), results are unweighted.- exclude
Variables or prefixes to exclude from tabulation. Defaults to
NULL. Always excludesweight(if specified) and any variable literally named "weight".- ...
Additional arguments passed to
tab_grid().
Details
This function assumes that the specified data frame only contains grid questions. Any non-grid question should be excluded using the exclude argument.
Examples
# Unweighted proportions tables of all grid questions
tab_grid_all(data = survey_data)
#> Error: These packages are required but not installed: dplyr
# Weighted proportions tables of all grid questions, excluding Q99
tab_grid_all(data = survey_data, weight = weight_var, exclude = "Q99")
#> Error: These packages are required but not installed: dplyr