
Formatted Analysis Function for Comparative Statistic in Response Tables (RESP01)
Source:R/resp01_functions.R
resp01_a_comp_stat_logical.RdThis function applies to a logical column called .var from df.
The response proportion is compared between the treatment arms identified
by column arm.
Usage
resp01_a_comp_stat_logical(
df,
.var,
conf_level,
include,
arm,
strata,
formats,
methods,
stat = c("comp_stat_ci", "pval")
)Arguments
- df
(
data.frame)
data set containing all analysis variables.- .var
(
string)
single variable name that is passed byrtableswhen requested by a statistics function.- conf_level
(
proportion)
confidence level of the interval.- include
(
flag)
whether to include the results for this variable.- arm
(
string)
column name in the data frame that identifies the treatment arms.- strata
(
characterorNULL)
variable names indicating stratification factors.- formats
(
list)
containing formats forcomp_stat_ciandpval.- methods
(
list)
containing methods for comparative statistics. The elementcomp_stat_cican be 'rr' (relative risk), 'or_cmh' (odds ratio with CMH estimation and p-value) or 'or_logistic' (odds ratio estimated by conditional or standard logistic regression). The elementpvalcan be 'fisher' (Fisher's exact test) or 'chisq' (chi-square test), only used when using unstratified analyses with 'or_logistic'.- stat
(
string)
the statistic to return, eithercomp_stat_ciorpval.
Value
The formatted result as rtables::rcell().
See also
resp01_a_comp_stat_factor() for the factor equivalent.
Examples
dm <- droplevels(subset(formatters::DM, SEX %in% c("F", "M")))
dm$RESP <- as.logical(sample(c(TRUE, FALSE), size = nrow(DM), replace = TRUE))
resp01_a_comp_stat_logical(
dm,
.var = "RESP",
conf_level = 0.9,
include = TRUE,
arm = "SEX",
strata = "RACE",
stat = "comp_stat_ci",
method = list(comp_stat_ci = "or_cmh"),
formats = list(
comp_stat_ci = jjcsformat_xx("xx.xx (xx.xx - xx.xx)"),
pval = jjcsformat_pval_fct(0.05)
)
)
#> rcell: 0.98 (0.69 - 1.38)