tbl1: Creates and formats a typical Table 1 for categorical and...

Description Usage Arguments Details Author(s) Examples

View source: R/tbl1.R

Description

The tbl1() function will create a typical descriptive table for categorical and continuous variables. Frequencies are stratified by an exposure variable. Percentages can be calculated as column or row percents.

Usage

1
tbl1(dat, variable, stratvar, percents=2, freq.type=0)

Arguments

dat

A data.frame in which to interpret the variables used in the function.

variable

Main frequency variable or vector of variables. In an N*N table, this would correspond to the rows

stratvar

Strata variable. In an N*N table, this would correspond to the columns

percents

1=row percents; 2=column percents (default); 0=overall percents

freq.type

0=Both N and (percent); 1= N-only; 2=Percentages-only

Details

The tbl1() function will take any set of variables and calculate frequencies (N and percentages) across strata of another variable and format the output typical for BERG Table 1 publications. Output for continuous variables will be mean (SD), categorical variables will be N (percent). Total output is formatted so that continuous variables are at the top of the table, followed by results for categorical variables. Final output is a data frame.

Author(s)

Brian Carter

Examples

1
2
3
4
df <- example_data
table1 <- tbl1(dat=df,
          variable=c("bmi92","age92m","smoke92","educ"),
          stratvar="myeloid")

buddha2490/BERG documentation built on Feb. 7, 2020, 6:01 p.m.