T_hss_table_multi: Create contingency table for multiresponse question

View source: R/T_hss_table_multi.R

T_hss_table_multiR Documentation

Create contingency table for multiresponse question

Description

Create contingency tables for HSS questions with multiple response options and a cross-variable. This function requires only a single question variable as input and looks up the corresponding response variables. 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, N-values are added to column headers, and a column containing p-values for chi-squared statistical test for each response option is added.

Usage

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

Arguments

df

The dataframe containing the multiresponse questions

var

The name of the question variable.

group

A 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 containing the multiresponse answers and a grouping variable


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