make_table_one: Make Table One

Description Usage Arguments Value Examples

Description

This function allows you to make a Table One for manuscript publication in the Public Health Sciences

Usage

1
2
3
4
5
6
7
make_table_one(df, grouping_var, num_vars = NULL, num_display = "PM",
  binary_cat_vars = NULL, multiple_cat_vars = NULL,
  cat_display = "CP", subgroups_m = NULL,
  mean_vars_for_subgroups = NULL, subgroups_c = NULL,
  count_vars_for_subgroups = NULL, order_of_vars = NULL,
  export_rtf = FALSE, rtf_filename = NULL, show_pval = TRUE,
  digits = 2)

Arguments

df

Dataset containing covariates

grouping_var

Variable to group by (will be columns of table)

num_vars

Vector of numeric variables

num_display

How should numeric variable results be displayed? ('PM' for mean +- sd, 'PRS' for mean (sd))

binary_cat_vars

Vector of binary variables (in 0-1 format)

multiple_cat_vars

Vector of multiple level categorical variables

cat_display

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

subgroups_m

Vector of subgroup variables of interest (must be factors). NOTE: If you plan to analyze a categorical variable by itself and then also use it for subgroup analysis, it is advised to copy and rename the columns of the categorical variables you wish to use as subgroups (ie. rename variable to something like 'variable_sub“) so Table One can be properly sorted to reflect your specification in 'order_of_vars'. If the subgroup does not have a unique name, it will be sorted directly below the categorical variable.

mean_vars_for_subgroups

Vector of numeric variables from which to calculate mean and sd (must match vector position of corresponding subgroup variable)

subgroups_c

Subgroup variable of interest (must be factor, same naming suggestion as in 'subgroups_m“ above)

count_vars_for_subgroups

Factor variable from which to calculate counts and proportions

order_of_vars

A vector of all variables listed in the order of the rows you desire for your Table One.

export_rtf

Logical. Do you want to export an RTF to location specified in 'rtf_filename'?

rtf_filename

Must be quoted and include '.rtf' extension (See example)

show_pval

Logical. Should the p-value results be displayed?

digits

Number of digits to round decimals

Value

A sorted Table One including numeric, categorical and subgroup variables

Examples

1
2
3
4
5
6
7
## Not run: 
make_table_one(df = obpv_baseline, grouping_var = obpv_quintile, num_vars = num_vars,
binary_cat_vars = binary_cat_vars, multiple_cat_vars = multiple_cat_vars, display = 'CP',
subgroups_m = subgroups_m, mean_vars_for_subgroups = mean_vars, subgroups_c = subgroups_c, count_vars_for_subgroups = count_vars,
order_of_vars = var_order, export_rtf = TRUE, rtf_filename = 'my_location/my_filename.rtf', show_pval = TRUE, digits = 2)

## End(Not run)

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