We often want to split tables based on the values of one or more variables (e.g., lab measurement) and then paginate separately within each of those table subsections. In rtables
we do this via page by row splits.
Row splits can be declared page by splits by setting page_by = TRUE
in the split_rows_by*()
call, as below.
When page by splits are present, page titles are generated automatically by appending the split value (typically a factor level, though it need not be), to the page_prefix
, separated by a :
. By default, page_prefix
is name of the variable being split.
lyt2 <- basic_table(
title = "Study XXXXXXXX",
subtitles = c("subtitle YYYYYYYYYY", "subtitle2 ZZZZZZZZZ"),
main_footer = "Analysis was done using cool methods that are correct",
prov_footer = "file: /path/to/stuff/that/lives/there HASH:1ac41b242a"
) %>%
split_cols_by("ARM") %>%
split_rows_by("SEX", page_by = TRUE, page_prefix = "Patient Subset - Gender", split_fun = drop_split_levels) %>%
split_rows_by("STRATA1") %>%
analyze("AGE", mean, format = "xx.x")
tbl2 <- build_table(lyt2, DM)
cat(export_as_txt(tbl2, paginate = TRUE, page_break = "\n\n~~~~ Page Break ~~~~\n\n"))
# Study XXXXXXXX
# subtitle YYYYYYYYYY
# subtitle2 ZZZZZZZZZ
# Patient Subset - Gender: F
#
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A: Drug X B: Placebo C: Combination
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A
# mean 30.9 32.9 36.0
# B
# mean 34.9 32.9 34.4
# C
# mean 35.2 36.0 34.3
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
#
# Analysis was done using cool methods that are correct
#
# file: /path/to/stuff/that/lives/there HASH:1ac41b242a
#
#
# ~~~~ Page Break ~~~~
#
# Study XXXXXXXX
# subtitle YYYYYYYYYY
# subtitle2 ZZZZZZZZZ
# Patient Subset - Gender: M
#
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A: Drug X B: Placebo C: Combination
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A
# mean 35.1 31.1 35.6
# B
# mean 36.6 32.1 34.4
# C
# mean 37.4 32.8 32.8
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
#
# Analysis was done using cool methods that are correct
#
# file: /path/to/stuff/that/lives/there HASH:1ac41b242a
Page by row splits can be nested, but only within other page_by splits, they cannot be nested within traditional row splits. In this case, a page title for each page by split will be present on every resulting page, as seen below:
lyt3 <- basic_table(
title = "Study XXXXXXXX",
subtitles = c("subtitle YYYYYYYYYY", "subtitle2 ZZZZZZZZZ"),
main_footer = "Analysis was done using cool methods that are correct",
prov_footer = "file: /path/to/stuff/that/lives/there HASH:1ac41b242a"
) %>%
split_cols_by("ARM") %>%
split_rows_by("SEX", page_by = TRUE, page_prefix = "Patient Subset - Gender", split_fun = drop_split_levels) %>%
split_rows_by("STRATA1", page_by = TRUE, page_prefix = "Stratification - Strata") %>%
analyze("AGE", mean, format = "xx.x")
tbl3 <- build_table(lyt3, DM)
cat(export_as_txt(tbl3, paginate = TRUE, page_break = "\n\n~~~~ Page Break ~~~~\n\n"))
# Study XXXXXXXX
# subtitle YYYYYYYYYY
# subtitle2 ZZZZZZZZZ
# Patient Subset - Gender: F
# Stratification - Strata: A
#
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A: Drug X B: Placebo C: Combination
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# mean 30.9 32.9 36.0
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
#
# Analysis was done using cool methods that are correct
#
# file: /path/to/stuff/that/lives/there HASH:1ac41b242a
#
#
# ~~~~ Page Break ~~~~
#
# Study XXXXXXXX
# subtitle YYYYYYYYYY
# subtitle2 ZZZZZZZZZ
# Patient Subset - Gender: F
# Stratification - Strata: B
#
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A: Drug X B: Placebo C: Combination
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# mean 34.9 32.9 34.4
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
#
# Analysis was done using cool methods that are correct
#
# file: /path/to/stuff/that/lives/there HASH:1ac41b242a
#
#
# ~~~~ Page Break ~~~~
#
# Study XXXXXXXX
# subtitle YYYYYYYYYY
# subtitle2 ZZZZZZZZZ
# Patient Subset - Gender: F
# Stratification - Strata: C
#
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A: Drug X B: Placebo C: Combination
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# mean 35.2 36.0 34.3
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
#
# Analysis was done using cool methods that are correct
#
# file: /path/to/stuff/that/lives/there HASH:1ac41b242a
#
#
# ~~~~ Page Break ~~~~
#
# Study XXXXXXXX
# subtitle YYYYYYYYYY
# subtitle2 ZZZZZZZZZ
# Patient Subset - Gender: M
# Stratification - Strata: A
#
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A: Drug X B: Placebo C: Combination
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# mean 35.1 31.1 35.6
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
#
# Analysis was done using cool methods that are correct
#
# file: /path/to/stuff/that/lives/there HASH:1ac41b242a
#
#
# ~~~~ Page Break ~~~~
#
# Study XXXXXXXX
# subtitle YYYYYYYYYY
# subtitle2 ZZZZZZZZZ
# Patient Subset - Gender: M
# Stratification - Strata: B
#
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A: Drug X B: Placebo C: Combination
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# mean 36.6 32.1 34.4
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
#
# Analysis was done using cool methods that are correct
#
# file: /path/to/stuff/that/lives/there HASH:1ac41b242a
#
#
# ~~~~ Page Break ~~~~
#
# Study XXXXXXXX
# subtitle YYYYYYYYYY
# subtitle2 ZZZZZZZZZ
# Patient Subset - Gender: M
# Stratification - Strata: C
#
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# A: Drug X B: Placebo C: Combination
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
# mean 37.4 32.8 32.8
# ââââââââââââââââââââââââââââââââââââââââââââââââââ
#
# Analysis was done using cool methods that are correct
#
# file: /path/to/stuff/that/lives/there HASH:1ac41b242a
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4