Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


rtables (version 0.6.6)

basic_table: Layout with 1 column and zero rows

Description

Every layout must start with a basic table.

Usage

basic_table(
  title = "",
  subtitles = character(),
  main_footer = character(),
  prov_footer = character(),
  header_section_div = NA_character_,
  show_colcounts = FALSE,
  colcount_format = "(N=xx)",
  inset = 0L
)

Value

A PreDataTableLayouts object suitable for passing to further layouting functions, and to build_table.

Arguments

title

character(1). Main title (main_title()) is a single string. Ignored for subtables.

subtitles

character. Subtitles (subtitles()) can be vector of strings, where every element is printed in a separate line. Ignored for subtables.

main_footer

character. Main global (non-referential) footer materials (main_footer()). If it is a vector of strings, they will be printed on separate lines.

prov_footer

character. Provenance-related global footer materials (prov_footer()). It can be also a vector of strings, printed on different lines. Generally should not be modified by hand.

header_section_div

character(1). String which will be used to divide the header from the table. See header_section_div() for getter and setter of these. Please consider changing last element of section_div() when concatenating tables that need a divider between them.

show_colcounts

logical(1). Should column counts be displayed in the resulting table when this layout is applied to data

colcount_format

character(1). Format for use when displaying the column counts. Must be 1d, or 2d where one component is a percent. See details.

inset

numeric(1). Number of spaces to inset the table header, table body, referential footnotes, and main_footer, as compared to alignment of title, subtitle, and provenance footer. Defaults to 0 (no inset).

Details

colcount_format is ignored if show_colcounts is FALSE (the default). When show_colcounts is TRUE, and colcount_format is 2-dimensional with a percent component, the value component for the percent is always populated with 1 (i.e. 100%). 1d formats are used to render the counts exactly as they normally would be, while 2d formats which don't include a percent, and all 3d formats result in an error. Formats in the form of functions are not supported for colcount format. See formatters::list_valid_format_labels() for the list of valid format labels to select from.

Examples

Run this code

lyt <- basic_table() %>%
  analyze("AGE", afun = mean)

tbl <- build_table(lyt, DM)
tbl

lyt2 <- basic_table(
  title = "Title of table",
  subtitles = c("a number", "of subtitles"),
  main_footer = "test footer",
  prov_footer = paste(
    "test.R program, executed at",
    Sys.time()
  )
) %>%
  split_cols_by("ARM") %>%
  analyze("AGE", mean)

tbl2 <- build_table(lyt2, DM)
tbl2

lyt3 <- basic_table(
  show_colcounts = TRUE,
  colcount_format = "xx. (xx.%)"
) %>%
  split_cols_by("ARM")

Run the code above in your browser using DataLab