MakeCountTables: Get counts and percentages from a table

View source: R/MakeCountTables.R

MakeCountTablesR Documentation

Get counts and percentages from a table

Description

Takes an input table and calculates the total and percentages for each variable. In order to ensure one row per observation, a id_var parameter is required.

Usage

MakeCountTables(data, id_var = NULL, group_var = NULL, rm_na = FALSE, sum_vars)

Arguments

data

the input table

id_var

the row-identifier column

group_var

the parameter to group the counts and percentages by

sum_vars

a vector of variables from the table to perform the operation on

Examples

## Note: must provide either an id_var or a group_var.

# N(%)s with a grouping variable
out <- MakeCountTables(data, id_var="MRN", group_var="Included_in_Study", sum_vars=c("Etiology", "Race", "Gender"))
print(out$Etiology)

# N(%s) without a grouping variable
out <- MakeCountTables(data, id_var="MRN", sum_vars=c("Etiology", "Race", "Gender"))
print(out$Etiology)

kwdoyle/kevtools documentation built on Jan. 4, 2023, 10:32 p.m.