tab1_fxn: Table Maker generic function to create a summary table of...

Usage Arguments Examples

View source: R/tab1.R

Usage

1
2
tab1_fxn(tab_in, ds, grp, pp = 1, mp = 1, test = F, denom = F,
  header = "both", long_cr = F)

Arguments

tab_in

data.frame with variables var, varnm, and type. optional variables group, target, test_interval, fisher

ds

dataset with variables referenced in tab_in

grp

name of variable to be used for grouping

pp

rounding digits for proportions

mp

rounding digits for mean/sd

test

boolean to request test of group differences

denom

boolean to request display of denominator in proportions

header

choose header for summary columns. "both" - "Percent (n) or Mean (SD)", "msd" - "Mean (SD)", np - "Percent (n)"

long_cr

boolean to request more details in parenthesis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
datas <- data.frame(grp=rep(c("A", "B", "C"), rep(100, 3)), 
var1 = rnorm(300, 0,1) + rep(1:3, rep(100, 3)), 
var2 = sample(c("Yes", "No"), 300, replace=T), 
var3 = sample(c("X", "Y", "Z"), 300, replace=T))
tab_desc <- bind_rows(data.frame(var="var1", varnm="Variable 1", type="c"),
                      data.frame(var="var2", varnm="Variable 2", type="b", target="Yes"),
                      data.frame(var="var3", varnm="Variable 3", type="m"))
tab1 <- tab_desc %>% group_by(ordr=1:n()) %>% do(tab1_fxn(., datas, grp="grp", test=T)) %>% ungroup
tab1 %>% select(-ordr) %>% TIRC(rnames="Characteristic", rgroup_col="group")
grp_tirc(tab1 %>% select(-ordr), grp="grp", p="p")
grp_tirc(tab1 %>% select(-ordr, -N), grp="grp", p="p")

jachan1/repFxns documentation built on May 18, 2018, 6:24 p.m.