dta_test <- data.frame(
USUBJID = paste0("S", 1:12),
ARM = rep(LETTERS[1:3], each = 4),
AVAL = rep(LETTERS[1:3], each = 4)
) %>%
dplyr::mutate(is_rsp = AVAL == "A")
basic_table() %>%
split_cols_by("ARM") %>%
estimate_proportion(vars = "is_rsp") %>%
build_table(df = dta_test)
# Case with only logical vector.
rsp_v <- c(1, 0, 1, 0, 1, 1, 0, 0)
s_proportion(rsp_v)
# Example for Stratified Wilson CI
nex <- 100 # Number of example rows
dta <- data.frame(
"rsp" = sample(c(TRUE, FALSE), nex, TRUE),
"grp" = sample(c("A", "B"), nex, TRUE),
"f1" = sample(c("a1", "a2"), nex, TRUE),
"f2" = sample(c("x", "y", "z"), nex, TRUE),
stringsAsFactors = TRUE
)
s_proportion(
df = dta,
.var = "rsp",
variables = list(strata = c("f1", "f2")),
conf_level = 0.90,
method = "strat_wilson"
)
Run the code above in your browser using DataLab