cat.var: Categorical Variable Summary

Description Usage Arguments Value Author(s) See Also Examples

View source: R/Table1.R

Description

This function produces counts, row percentages, column percentages, and counts of missing values for each level of a categorical variable input, optionally stratified by another variable, and with the option to compute p-values.

Usage

1
cat.var(var, strat, dec, rownames, header, ptype, pname, cat.rmstat, vspace, output)

Arguments

var

Categorical variable input. Required.

strat

Column stratifying variable. Optional.

dec

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

rownames

Ordered character vector of row names for each level of 'var'. Optional; defaults to the value of each factor level.

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. Optional; defaults to FALSE.

cat.rmstat

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

"count"

Remove overall count/percent

"row"

Remove row percents, leaving only column percents

"col"

Remove column percents, leaving only row percents

"miss"

Remove summary of missing values

vspace

TRUE for additional vertical whitespace between variables (default).

output

Output type passed from make.table.

Value

Returns a data frame of categorical summary statistics.

Author(s)

Erica Wozniak

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(survival)

# Default output
cat.var(var   = pbc$hepato, 
        strat = pbc$sex
        )
        
# Naming options and p-value
cat.var(var      = pbc$hepato, 
        strat    = pbc$sex, 
        rownames = c("Not present", "Present"),
        header   = c("Hepatomegaly"),
        ptype    = "chisq"
        )
        
# Remove row percents, missing values, and name of statistical test used
cat.var(var        = pbc$hepato, 
        strat      = pbc$sex, 
        rownames   = c("Not present", "Present"),
        header     = c("Hepatomegaly"),
        ptype      = "chisq",
        cat.rmstat = c("row", "miss"),
        pname      = FALSE
        )       

emwozniak/Table1 documentation built on May 13, 2017, 6:06 p.m.