ttap: Access or set table elements at specified path

tt_at_pathR Documentation

Access or set table elements at specified path

Description

Access or set table elements at specified path

Usage

tt_at_path(tt, path, ...)

tt_at_path(tt, path, ...) <- value

Arguments

tt

(TableTree or related class)
a TableTree object representing a populated table.

path

(character)
a vector path for a position within the structure of a TableTree. Each element represents a subsequent choice amongst the children of the previous choice.

...

unused.

value

(ANY)
the new value.

Note

Setting NULL at a defined path removes the corresponding sub-table.

Examples

# Accessing sub table.
lyt <- basic_table() %>%
  split_cols_by("ARM") %>%
  split_rows_by("SEX") %>%
  split_rows_by("BMRKR2") %>%
  analyze("AGE")

tbl <- build_table(lyt, ex_adsl) %>% prune_table()
sub_tbl <- tt_at_path(tbl, path = c("SEX", "F", "BMRKR2"))

# Removing sub table.
tbl2 <- tbl
tt_at_path(tbl2, path = c("SEX", "F")) <- NULL
tbl2

# Setting sub table.
lyt3 <- basic_table() %>%
  split_cols_by("ARM") %>%
  split_rows_by("SEX") %>%
  analyze("BMRKR2")

tbl3 <- build_table(lyt3, ex_adsl) %>% prune_table()

tt_at_path(tbl3, path = c("SEX", "F", "BMRKR2")) <- sub_tbl
tbl3


Roche/rtables documentation built on April 30, 2024, 11:18 p.m.