-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Description
Hi @gmbecker ,
I ran into this problem, where I would appreciate your help.
Starting point:
lyt <- basic_table() |>
split_cols_by("ARM") |>
split_rows_by("STRATA1", page_by = TRUE) |>
split_rows_by("RACE", split_fun = keep_split_levels("ASIAN")) |>
analyze("AGE", mean, var_labels = "Age", format = "xx.xx") |>
split_rows_by("RACE", split_fun = keep_split_levels("BLACK OR AFRICAN AMERICAN")) |>
analyze("AGE", mean, var_labels = "Age", format = "xx.xx") |>
analyze("BMRKR1", mean, var_labels = "Biomarker", format = "xx.xx")
build_table(lyt, DM)Gives:
A: Drug X B: Placebo C: Combination
———————————————————————————————————————————————————————————————————
A
ASIAN
mean 32.19 33.90 36.81
B
ASIAN
mean 34.12 31.62 34.73
C
ASIAN
mean 36.21 33.00 32.39
BLACK OR AFRICAN AMERICAN
Age
mean 34.68 31.71 34.00
Biomarker
mean 5.30 7.28 5.36
But I would like to produce a table where the second row split of RACE is nested within the page split. So something like:
A: Drug X B: Placebo C: Combination
———————————————————————————————————————————————————————————————————
A
ASIAN
mean 32.19 33.90 36.81
BLACK OR AFRICAN AMERICAN
Age
mean 34.68 31.71 34.00
Biomarker
mean 5.30 7.28 5.36
B
ASIAN
mean 34.12 31.62 34.73
BLACK OR AFRICAN AMERICAN
Age
mean 34.68 31.71 34.00
Biomarker
mean 5.30 7.28 5.36
C
ASIAN
mean 36.21 33.00 32.39
BLACK OR AFRICAN AMERICAN
Age
mean 34.68 31.71 34.00
Biomarker
mean 5.30 7.28 5.36
How can I do that?
Edit: Actually it is not just for page by row split, it also is the same question for a normal row split:
lyt <- basic_table() |>
split_cols_by("ARM") |>
split_rows_by("STRATA1") |>
split_rows_by("RACE", split_fun = keep_split_levels("ASIAN")) |>
analyze("AGE", mean, var_labels = "Age", format = "xx.xx") |>
split_rows_by("RACE", split_fun = keep_split_levels("BLACK OR AFRICAN AMERICAN")) |>
analyze("AGE", mean, var_labels = "Age", format = "xx.xx") |>
analyze("BMRKR1", mean, var_labels = "Biomarker", format = "xx.xx")
build_table(lyt, DM)gives:
A: Drug X B: Placebo C: Combination
———————————————————————————————————————————————————————————————————
A
ASIAN
mean 32.19 33.90 36.81
B
ASIAN
mean 34.12 31.62 34.73
C
ASIAN
mean 36.21 33.00 32.39
BLACK OR AFRICAN AMERICAN
Age
mean 34.68 31.71 34.00
Biomarker
mean 5.30 7.28 5.36
> sessionInfo()
R version 4.4.2 (2024-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)
Matrix products: default
locale:
[1] LC_COLLATE=German_Switzerland.utf8 LC_CTYPE=German_Switzerland.utf8
[3] LC_MONETARY=German_Switzerland.utf8 LC_NUMERIC=C
[5] LC_TIME=German_Switzerland.utf8
time zone: Asia/Taipei
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rtables_0.6.11 magrittr_2.0.3 formatters_0.5.10
loaded via a namespace (and not attached):
[1] compiler_4.4.2 backports_1.5.0 fastmap_1.2.0 cli_3.6.3 htmltools_0.5.8.1
[6] tools_4.4.2 rstudioapi_0.17.1 stringi_1.8.4 grid_4.4.2 checkmate_2.3.2
[11] pkgload_1.4.0 digest_0.6.37 lifecycle_1.0.4 rlang_1.1.5 Thanks,
cheers
Daniel
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels