tableFunc: Format for printing frequency and percentages

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/tableFunc.R

Description

Meant to be used in creating R matrix to be exported as a table

Usage

1
tableFunc(data, fvar, gvar = NULL, level = NULL, digits = 1)

Arguments

data

Data frame where nvar and gvar can be found

fvar

Character string of column in data of factor data

gvar

Character string of column in data of grouping data

level

Character string of level of fvar to be reported. If null then all levels are printed

digits

Number of decimals to be printed

Details

table(fvar,gvar) and 100*prop.table(table(fvar,gvar),2) are used to create N (%) for each level of fvar by gvar. If only 1 level is needed (i.e. Yes/No variable only needs Yes to be reported) then level can specify which level to print

Value

Returns a vector of strings of N (%) from table(fvar,gvar) with columns printed first. If gvar is NULL then N (%) of fvar is returned.

Author(s)

University of Wisconsin-Madison Biostatistics and Medical Informatics Department, Scott Hetzel M.S.

See Also

chisqFunc

Examples

1
2
3
4
5
6
set.seed(784)
outcome <- factor(sample(c("No", "Yes"), replace = TRUE, size = 20))
group <- factor(rep(c("A", "B"), each = 10))
d.frame <- data.frame(outcome, group)

tableFunc(d.frame, "outcome", "group", level = "Yes")

jbirstler/biostatrpts documentation built on May 7, 2020, 12:10 a.m.