Closed Melkiades closed 2 months ago
Also, is there a simpler way to resort the columns?
This is a way:
library(rtables)
#> Loading required package: formatters
#>
#> Attaching package: 'formatters'
#> The following object is masked from 'package:base':
#>
#> %||%
#> Loading required package: magrittr
#>
#> Attaching package: 'rtables'
#> The following object is masked from 'package:utils':
#>
#> str
reorder_facets <- function(splret, spl, fulldf, ...) {
ord <- c(1, 3, 4, 2, 5)
make_split_result(
splret$values[ord],
splret$datasplit[ord],
splret$labels[ord]
)
}
custom_column_split_fun <- make_split_fun(
post = list(
add_combo_facet("all_X",
label = "All Drug X",
levels = c("A: Drug X", "C: Combination")
),
add_combo_facet("all_pt",
label = "All Patients",
levels = c("A: Drug X", "B: Placebo", "C: Combination")
),
reorder_facets
)
)
lyt <- basic_table(show_colcounts = TRUE) %>%
split_cols_by(
"ACTARM",
split_fun = custom_column_split_fun
) %>%
analyze("BMRKR1")
build_table(lyt, ex_adsl)
#> A: Drug X C: Combination All Drug X B: Placebo All Patients
#> (N=134) (N=132) (N=266) (N=134) (N=400)
#> ——————————————————————————————————————————————————————————————————————————
#> Mean 5.97 5.62 5.80 5.70 5.76
Created on 2024-06-28 with reprex v2.1.0
Is there one to do this in post-processing @gmbecker?
Closing this as the workaround solves the issue nicely and it is ultimately the right way to go for this.
The following issue is coming from a similar one in the tlg catalog. it was working before col_counts PR. There are different ways to work this in (changing split_fun) but I am wondering if this is a bug @gmbecker
Created on 2024-06-25 with reprex v2.1.0