tabler_stat2 | R Documentation |
tabler_stat
wrappersHelper functions for using tabler_stat
.
tabler_stat2(
data,
varname,
byvar = NULL,
varname_label = names(varname),
byvar_label = names(byvar),
digits = NULL,
FUN = NULL,
confint = FALSE,
survmedian = FALSE,
survtime = FALSE,
time = 0,
total = TRUE,
n = NULL,
include_na_in_prop = TRUE,
iqr = FALSE,
format_pval = TRUE,
color_pval = TRUE,
correct = FALSE,
color_missing = TRUE,
dagger = TRUE,
group = NULL,
color_cell_by = "none",
cell_color = palette()[1:2],
statArgs = NULL,
align = NULL,
rgroup = NULL,
cgroup = NULL,
tfoot = NULL,
tfoot2 = NULL,
htmlArgs = NULL,
zeros = "-",
clean_daggers = FALSE
)
data |
a matrix or data frame with variables |
varname |
one or more variables in |
byvar |
a stratification variable; the column variable of the table |
varname_label , byvar_label |
optional labels for each note that duplicated |
digits |
alternatively, to set |
FUN |
|
confint |
optional vector of |
survmedian , survtime , time |
survival object options - median survival or survival time |
total |
logical; if |
n |
(optional) the sample size for each column used to calculate percents; if length 1, recycled as necessary; if length > 1, length must be the same as the number of columns in the table including total |
include_na_in_prop |
logical; if |
iqr |
logical; if |
format_pval |
logical; if |
color_pval , color_missing , dagger |
|
correct |
logical or one of |
group |
a named vector of variables (either index of or a
value in |
color_cell_by , cell_color |
apply a color gradient ( |
statArgs |
a named list of additional arguments passed to
|
align , rgroup , cgroup , tfoot |
optional arguments passed to
|
tfoot2 |
optional footnote(s) appended to |
htmlArgs |
a named list of additional arguments passed to
|
zeros |
a character string used in place of zero cells (non-character value keeps cells as-is) |
clean_daggers |
logical or one of |
tabler_stat
; rawr:::get_tabler_stat_n
rawr:::guess_digits
; rawr:::name_or_index
rawr:::tabler_stat_list
; rawr:::tabler_stat_html
Other tabler:
tabler()
,
tabler_by()
,
tabler_resp()
,
tabler_stat()
sapply(mtcars[1:6], rawr:::guess_digits)
Map(rawr::roundr, mtcars[1:6], sapply(mtcars[1:6], rawr:::guess_digits))
rawr:::get_tabler_stat_n(mtcars$gear)
## typical usage
mt <- within(mtcars, {
cyl <- factor(cyl)
mpg2 <- factor(+(mpg > 20), 0:1, c('≤ 20', '> 20'))
})
tabler_stat2(mt, c('mpg', 'cyl', 'wt'))
tabler_stat2(mt, c('mpg', 'cyl', 'wt'), 'vs')
tabler_stat2(mt, c('mpg', 'cyl', 'wt'), 'vs', group = 'wt')
tabler_stat2(mt, c('mpg', 'cyl', 'wt'), 'vs',
group = c(group1 = 1, 'Weight' = 3))
tabler_stat2(mt, c('mpg', 'cyl', 'wt'), 'vs',
FUN = list('kruskal', 'fisher', FALSE))
tabler_stat2(
mt, c('mpg', 'cyl', 'wt'), 'vs',
cgroup = c('', 'V/S engine', ''),
rgroup = c('Miles/gallon', 'No. cylinders', 'Weight (1000 lbs)')
)
tabler_stat2(
mt,
varname = c(MPG = 'mpg', MPG = 'mpg2', Cylinders = 'cyl', Weight = 'wt'),
byvar = c('V/S engine' = 'vs'),
confint = c('mpg2', 'cyl'),
zeros = NULL,
digits = c(wt = 2)
# digits = c('3' = 2) ## equivalently
)
## multiple column variables
tabler_stat2(mt, c('mpg', 'cyl', 'wt'), c('vs', 'gear'), FUN = NA)
## Not run:
## experimental -- row- or column-merge tables
h1 <- tabler_stat2(mt, c('mpg', 'cyl', 'wt'), 'vs')
h2 <- tabler_stat2(mt, c('mpg', 'cyl', 'wt'), 'am')
h3 <- tabler_stat2(mt, c('mpg', 'cyl', 'wt'), 'gear')
rawr:::combine_tabler_stat2(list(h1, h2), how = 'rbind')
rawr:::combine_tabler_stat2(list(table1 = h1, table2 = h2), how = 'rbind')
rawr:::combine_tabler_stat2(list(h1, h2, h3), how = 'cbind')
rawr:::combine_tabler_stat2(list(t1 = h1, t2 = h2, t3 = h3), how = 'cbind')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.