T_hss_table_single: Create contingency table for single-response question

View source: R/T_hss_table_single.R

T_hss_table_singleR Documentation

Create contingency table for single-response question

Description

Create contingency tables for HSS questions with a single response option and a cross-variable. Tables can be created with either counts or percentages and the number of significant digits for percentages can be set. Tables created with this function come with a couple of additions according to HSS preferences. Most notably: sums are added over columns, and N-values are added to column headers.

Usage

T_hss_table_single(df, var, group, percent = TRUE, digits = 1)

Arguments

df

A dataframe containing the variable of interest and grouping variable.

var

A character string with the variable name of interest.

group

A character string with the grouping (or disaggregation) variable.

percent

Set to TRUE to show percentages. Set to FALSE to show counts.

digits

The number of (significant) digits to display. Trailing zeroes are always removed. Note that 'digits' does not mean 'decimals', so digits = 3 will display as 'mm.d' not 'mm.ddd'

Value

A contingency table with the variable of interest and grouping variable.

See Also

T_hss_table_multi


RenRMT/hsstools documentation built on April 14, 2025, 7:10 p.m.