tabler_resp | R Documentation |
Convenience function to calculate proportions and confidence intervals and format for easy display.
tabler_resp(
x,
r_or_better = levels(x)[3:2],
conf = 0.95,
digits = 0L,
frac = TRUE,
show_conf = TRUE,
pct.sign = TRUE,
total = FALSE,
two_stage = FALSE
)
x |
a factor variable of responses; responses should be ordered as CR, PR, SD, PD, NE or similar (i.e., best to worst) |
r_or_better |
if integer(s), indicates the levels of if |
conf , frac , show_conf , pct.sign |
additional arguments passed to
|
digits |
number of digits past the decimal point to keep |
total |
logical or numeric; if |
two_stage |
if more than three integers are given, the remaining should indicate the column(s) which should be calculated as two-stage CIs |
bincon
; binconr
; response
Other tabler:
tabler()
,
tabler_by()
,
tabler_stat()
,
tabler_stat2()
set.seed(1)
r <- c('CR', 'PR', 'SD', 'PD', 'NE')
x <- factor(sample(r, 30, replace = TRUE), r)
tabler_resp(x)
tabler_resp(x, 3)
tabler_resp(x, 'PR')
tabler_resp(x, 'PR', total = 50)
## note NAs are removed
y <- replace(x, 1:10, value = NA)
tabler_resp(x, FALSE)
tabler_resp(y, FALSE)
## two-stage designs
two_stage <- c(r1 = 2, n1 = 10, n2 = 20)
tabler_resp(x, two_stage = c(two_stage))
## two-stage only for SD or better and PR or better
tabler_resp(x, two_stage = c(two_stage, 6:7))
## compare
bincon(c(2, 20), c(10, 20), method = 'two-stage') ## SD or better
bincon(c(2, 16), c(10, 20), method = 'two-stage') ## PR or better
## one-stage methods should not be used
bincon(c(20, 16), 30, method = 'exact')
## typical usage
ht <- htmlTable::htmlTable(
rbind(
'95% CI' = tabler_resp(x),
'90% CI' = tabler_resp(x, conf = 0.9),
'Simple' = tabler_resp(x, frac = FALSE, pct.sign = FALSE,
show_conf = FALSE, digits = 1),
'Two-stage' = tabler_resp(x, two_stage = c(2, 10, 20, 6:7))
),
caption = 'Table of responses with exact binomial and
two-stage<sup>†</sup>confidence intervals.',
css.cell = 'padding: 0 10 0px; white-space: nowrap;',
cgroup = c('Evaluation', 'Outcome (95% CI)'),
n.cgroup = c(nlevels(x), 2L)
)
structure(ht, class = 'htmlTable')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.