Table1: Create a table one

Description Usage Arguments Details Value Methods (by class)

View source: R/Table1.R

Description

This is a function created to provide characteristics of a study group with an option to stratify by some variable (usually an exposure) The output of this function is designed to be used with pander in rmarkdown, but all row name formatting can be removed with the option: emphasis = 'n'.

Usage

1
2
3
4
5
6
7
Table1(data, ...)

## S3 method for class 'data.frame'
Table1(data, rowvars, colvar, sigfig = 4,
  rowvar_names = NULL, incl_missing = TRUE, incl_pvalues = FALSE,
  emphasis = c("b", "s", "n"), MedIQR = NULL, asTable = TRUE,
  lineBreaks = T, tight = TRUE, verbose = FALSE, ...)

Arguments

data

the data frame or design object of the data you which to characterize

...

Arguments passed through methods to table 1.

rowvars

A vector of row positions or names.

colvar

The position or name of the variable to stratify by, set to NULL for no stratification.(p values cannot be returned if NULL)

sigfig

The number of significant digits to use for mean, sd, median, and IQR.

rowvar_names

An optional vector of row names to be used for variables. Must be the same length and in the same order as rowvars.

incl_missing

Set to TRUE to include missing values (default)

incl_pvalues

Set to TRUE to include p values (p values are only calculated on non missing observations) (default = FALSE)

emphasis

Set to 's' for to indent categories for categorical values, 'b' to bold just variable names, and 'n' for no emphasis.

MedIQR

optional vector of continuous variables to return median and IQR instead of mean and SD.

asTable

should a table (TRUE) or a matrix be returned

lineBreaks

should the N be printed on a seperate line from the categories. default is TRUE (see details)

tight

if TRUE (default) no spaces between numbers and parenthesis

verbose

should both levels of binary variables be printed.

Details

Only the 1st factor of binary categorical variables is displayed. All determinations of categorical, binary, or continuous are performed automatically. Character variables are converted to factors. Variables are displayed in the following order: binary, non-binary categorical, continuous, and integers + continuous variables with median and IQR. If no stratification variable is provided, summary statistics on the entire sample are provided. No p-values can be provided in this case. If a design object is passed in lieu of a data frame, weighted numbers using the survey package are provided. (The survey package must be installed in this case.)

To use the lineBreaks use panderOptions('keep.line.breaks', TRUE)

Value

a table/matrix with N and percentages for categorical variables, mean and sd for continuous ones, and median and 25th and 75th percentile for integers. If variables are passed via the MedIQR argument, median and 25th and 75th percentile is calculated instead for those variable.

Methods (by class)


ledbettc/CIDAtools documentation built on Jan. 24, 2020, 3:56 p.m.