'can you use split_cols_by and also get a total column?
I'm making a table like this:
basic_table() %>%
split_cols_by("ARM") %>%
analyze(vars = c("AGE", "BMRKR1"), afun = function(x) {
in_rows(
"Mean (sd)" = rcell(c(mean(x), sd(x)), format = "xx.xx (xx.xx)"),
"Range" = rcell(range(x), format = "xx.xx - xx.xx")
)
}) %>%
build_table(ADSL)
with looks like this
A: Drug X B: Placebo C: Combination
----------------------------------------------------------
AGE
Mean (sd) 33.77 (6.55) 35.43 (7.9) 35.43 (7.72)
Range 21 - 50 21 - 62 20 - 69
BMRKR1
Mean (sd) 5.97 (3.55) 5.7 (3.31) 5.62 (3.49)
Range 0.41 - 17.67 0.65 - 14.24 0.17 - 21.39
(see https://cran.r-project.org/web/packages/rtables/vignettes/clinical_trials.html)
I would like to get an additional column, which includes all the data - is that possible?
Solution 1:[1]
I think you are looking for:
split_cols_by("ARM", split_fun=add_overall_level("All", first=FALSE))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | knokknok |
