summarize_all_categorical: Summarize All Categorical Variables

Description Usage Arguments Value Examples

Description

This function allows you to calculate counts, proportions, or a combination of both for all binary or multiple level categorical variables in a dataset. The function will take two vectors of categorical variables split by 'binary' and 'multiple' levels. NOTE: ALL CATEGORICAL VARIABLES MUST BE CONVERTED TO FACTORS BEFORE USING THIS FUNCTION. For binary variables, make sure vairables are coded as 0-1. This function will produce output for the case where the binary variable equals 1. If both levels of the binary variable are desired, include the binary variable in the 'multiple' level categorical variable vector. For 'display' options: 'CP' = counts and proportions, 'C' = counts, and 'P' = proportions (defaults to 'CP')

Usage

1
2
summarize_all_categorical(df, binary_cat_vars, multiple_cat_vars,
  grouping_var, display = "CP", show_pval = TRUE, digits = 1)

Arguments

df

Dataset containing covariates of interest

binary_cat_vars

Vector of binary variables (in 0-1 format)

multiple_cat_vars

Vector of multiple level categorical variables

grouping_var

Variable to group by (will be columns of table)

display

How to display results: 'CP' = counts and proportions, 'C' = counts, 'P' = proportions (defaults to 'CP')

digits

Number of digits to round decimals

Value

A data frame summarizing mean/sd of covariate at each level of grouping variable

Examples

1
2
3
4
5
## Not run: 
summarize_all_categorical(df = obpv_baseline, binary_cat_vars = binary_cat_vars,
multiple_cat_vars = multiple_cat_vars, grouping_var = obpv_quintile, display = 'CP', digits = 1)

## End(Not run)

jjwillard/wfbmcphsr documentation built on May 14, 2019, 5:01 a.m.