A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cran.r-project.org/web/packages/sitar/../rmarkdown/../rtables/vignettes/title_footer.html below:

Titles, Footers, and Referential Footnotes

Page-by splitting

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