Learn R Programming

rtables (version 0.6.6)

add_overall_level: Add an virtual 'overall' level to split

Description

Add an virtual 'overall' level to split

Usage

add_overall_level(
  valname = "Overall",
  label = valname,
  extra_args = list(),
  first = TRUE,
  trim = FALSE
)

Value

a closure suitable for use as a splitting function (splfun) when creating a table layout

Arguments

valname

character(1). 'Value' to be assigned to the implicit all-observations split level. Defaults to "Overall"

label

character(1). A label (not to be confused with the name) for the object/structure.

extra_args

list. Extra arguments to be passed to the tabulation function. Element position in the list corresponds to the children of this split. Named elements in the child-specific lists are ignored if they do not match a formal argument of the tabulation function.

first

logical(1). Should the implicit level appear first (TRUE) or last FALSE. Defaults to TRUE.

trim

logical(1). Should splits corresponding with 0 observations be kept when tabulating.

Examples

Run this code

lyt <- basic_table() %>%
  split_cols_by("ARM", split_fun = add_overall_level("All Patients",
    first = FALSE
  )) %>%
  analyze("AGE")

tbl <- build_table(lyt, DM)
tbl

lyt2 <- basic_table() %>%
  split_cols_by("ARM") %>%
  split_rows_by("RACE",
    split_fun = add_overall_level("All Ethnicities")
  ) %>%
  summarize_row_groups(label_fstr = "%s (n)") %>%
  analyze("AGE")
lyt2

tbl2 <- build_table(lyt2, DM)
tbl2

Run the code above in your browser using DataLab