
Last chance! 50% off unlimited learning
Sale ends in
Retrieve cell values by row and column path
cell_values(tt, rowpath = NULL, colpath = NULL, omit_labrows = TRUE)# S4 method for VTableTree
cell_values(tt, rowpath = NULL, colpath = NULL, omit_labrows = TRUE)
# S4 method for TableRow
cell_values(tt, rowpath = NULL, colpath = NULL, omit_labrows = TRUE)
# S4 method for LabelRow
cell_values(tt, rowpath = NULL, colpath = NULL, omit_labrows = TRUE)
value_at(tt, rowpath = NULL, colpath = NULL)
# S4 method for VTableTree
value_at(tt, rowpath = NULL, colpath = NULL)
# S4 method for TableRow
value_at(tt, rowpath = NULL, colpath = NULL)
# S4 method for LabelRow
value_at(tt, rowpath = NULL, colpath = NULL)
for cell_values
, a list (regardless of the type of
value the cells hold). if rowpath
defines a path to a single row,
cell_values
returns the list of cell values for that row, otherwise
a list of such lists, one for each row captured underneath rowpath
.
This occurs after subsetting to colpath
has occurred.
For value_at
the "unwrapped" value of a single cell, or an error, if
the combination of rowpath
and colpath
do not define the
location of a single cell in tt
.
TableTree (or related class). A TableTree object representing a populated table.
character. Path in row-split space to the desired row(s). Can
include "@content"
.
character. Path in column-split space to the desired
column(s). Can include "*"
.
logical(1). Should label rows underneath rowpath
be omitted (TRUE
, the default), or return empty lists of cell
"values" (FALSE
).
lyt <- basic_table() %>%
split_cols_by("ARM") %>%
split_cols_by("SEX") %>%
split_rows_by("RACE") %>%
summarize_row_groups() %>%
split_rows_by("STRATA1") %>%
analyze("AGE")
library(dplyr) ## for mutate
tbl <- build_table(lyt, DM %>%
mutate(SEX = droplevels(SEX), RACE = droplevels(RACE)))
row_paths_summary(tbl)
col_paths_summary(tbl)
cell_values(tbl, c("RACE", "ASIAN", "STRATA1", "B"),
c("ARM", "A: Drug X", "SEX", "F"))
# it's also possible to access multiple values by being less specific
cell_values(tbl, c("RACE", "ASIAN", "STRATA1"),
c("ARM", "A: Drug X", "SEX", "F"))
cell_values(tbl, c("RACE", "ASIAN"), c("ARM", "A: Drug X", "SEX", "M"))
## any arm, male columns from the ASIAN content (ie summary) row
cell_values(tbl, c("RACE", "ASIAN", "@content"),
c("ARM", "B: Placebo", "SEX", "M"))
cell_values(tbl, c("RACE", "ASIAN", "@content"),
c("ARM", "*", "SEX", "M"))
## all columns
cell_values(tbl, c("RACE", "ASIAN", "STRATA1", "B"))
## all columns for the Combination arm
cell_values(tbl, c("RACE", "ASIAN", "STRATA1", "B"),
c("ARM", "C: Combination"))
cvlist <- cell_values(tbl, c("RACE", "ASIAN", "STRATA1", "B", "AGE", "Mean"),
c("ARM", "B: Placebo", "SEX", "M"))
cvnolist <- value_at(tbl, c("RACE", "ASIAN", "STRATA1", "B", "AGE", "Mean"),
c("ARM", "B: Placebo", "SEX", "M"))
stopifnot(identical(cvlist[[1]], cvnolist))
Run the code above in your browser using DataLab