cell_values | R Documentation |
Retrieve cell values by row and column path
cell_values(tt, rowpath = NULL, colpath = NULL, omit_labrows = TRUE)
value_at(tt, rowpath = NULL, colpath = NULL)
## S4 method for signature 'VTableTree'
value_at(tt, rowpath = NULL, colpath = NULL)
tt |
( |
rowpath |
( |
colpath |
( |
omit_labrows |
( |
cell_values
returns 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.
value_at
returns 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
.
cell_values
will return a single cell's value wrapped in a list. Use value_at
to receive the "bare" cell
value.
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 (i.e. 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.