quantify_categorical: Quantify Categorical Variable

Description Usage Arguments Value Examples

Description

This function allows you to calculate counts, proportions, or a combination of both for binary or multiple level categorical variables. NOTE: ALL CATEGORICAL VARIABLES MUST BE CONVERTED TO FACTORS BEFORE USING THIS FUNCTION. For binary variables, make sure vairables are coded as 0-1 and choose ‘type = ’binary''. This will produce output for the case where the variable equals 1. If both levels of the binary variable are desired, choose ‘type = ’multiple'' which produces output for all levels of the categorical variable.

Usage

1
2
quantify_categorical(covariate, df, grouping_var, type = c("multiple",
  "binary"), display = "CP", show_pval = TRUE, digits = 1)

Arguments

covariate

Categorical variable of interest

df

Dataset containing covariate

grouping_var

Variable to group by (will be columns of table)

type

Type of categorical variable: 'binary' or 'multiple' (Note: If you would like to see both levels of a binary variable in the output, then specify 'multiple').

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 counts/proportions of categorical variable at each level of grouping variable

Examples

1
2
3
4
5
## Not run: 
quantify_categorical(covariate = Edu_4cat, obpv_baseline, grouping_var = obpv_quintile,
type = 'multiple', display = 'CP')

## End(Not run)

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