cont.var: Continuous Variable Summary

View source: R/Table1.R

cont.varR Documentation

Continuous Variable Summary

Description

This function computes the mean (SD), median (IQR), Q1/Q3, min/max, and a count of missings for a continuous variable input, optionally stratified by another variable, and with the option to compute p-values.

Usage

cont.var(var, strat, dec, header, ptype, pname, cont.rmstat, vspace, output)

Arguments

var

Continuous variable input. Required.

strat

Column stratifying variable. Optional.

dec

Number of decimal places on summary statistics. Optional; defaults to 2.

header

Character vector providing a short variable description. Optional; defaults to variable name.

ptype

Statistical test for p-value. Optional; defaults to none. See stat.col for a complete list of options.

pname

If TRUE then the name of the statistical test used will be printed below the p-value (default). Optional.

cont.rmstat

Vector naming the statistics that should be removed from the summary data frame. Optional; defaults to none.

"count"

Remove overall count

"meansd"

Remove mean and standard deviation

"mediqr"

Remove median and interquartile range

"q1q3"

Remove 25th and 75th percentiles

"minmax"

Remove minimum and maximum

"miss"

Remove summary of missing values

vspace

TRUE for additional vertical whitespace between variables (default). Optional.

output

Output type passed from make.table.

Details

Note that warnings and errors beyond those automatically provided by some base R functions are not in place for the improper use of significance testing. For example, if a t-test is requested across more than two strata, the code will execute and the returned p-value will reflect a test of only the first two strata.

Value

Returns a data frame of continuous summary statistics.

Author(s)

Erica Wozniak

See Also

Table1 cat.var make.table quick.table stat.col out.plain out.latex out.html

Examples

library(survival)

# Default output 
cont.var(var   = pbc$age,
         strat = pbc$sex
         )
         
# Naming options and p-value         
cont.var(var    = pbc$age,
         strat  = pbc$sex,
         header = "Age",
         ptype  = "ttest"
         )
         
# Remove min/max and missing statistics, and test for p-value
cont.var(var         = pbc$age,
         strat       = pbc$sex,
         header      = "Age",
         ptype       = "ttest",
         cont.rmstat = c("minmax", "miss"),
         pname       = FALSE
         )

emwozniak/Table1 documentation built on Oct. 5, 2022, 12:20 a.m.