single_summary {surveyexplorer}R Documentation

Generate a summary table for a single categorical variable, providing counts and frequencies.

Description

This function analyzes a specified categorical variable, question, optionally grouping by another variable, group_by. Counts and frequencies are computed, taking into account provided survey weights. Subgroups can be excluded, and NAs can be removed if necessary.

Usage

single_summary(
  dataset,
  question,
  group_by = NULL,
  subgroups_to_exclude = NULL,
  weights = NULL,
  na.rm
)

Arguments

dataset

The input dataframe (or tibble) of survey questions

question

The categorical variable of interest for which frequencies and counts will be calculated, can be selected by using tidyselect semantics

group_by

Optional variable to group the analysis. If provided, the frequencies and counts will be calculated within each subgroup.

subgroups_to_exclude

Optional vector specifying subgroups to exclude from the analysis.

weights

Optional variable containing survey weights. If provided, frequencies and counts will be weighted accordingly.

na.rm

Logical indicating whether to remove NA values from question before analysis.

Value

A tabled data frame with counts and frequencies for the specified variable and optional grouping variable. The output is pre-processed, considering subgroup exclusions, NA removal, and survey weights if provided.

See Also

Other single-choice questions: single_freq(), single_table()


[Package surveyexplorer version 0.1.0 Index]