| matrix_form,VTableTree-method {rtables} | R Documentation |
Transform an rtable to a list of matrices which can be used for outputting
Description
Although rtables are represented as a tree data structure when outputting the table to ASCII or HTML
it is useful to map the rtable to an in-between state with the formatted cells in a matrix form.
Usage
## S4 method for signature 'VTableTree'
matrix_form(
obj,
indent_rownames = FALSE,
expand_newlines = TRUE,
indent_size = 2,
fontspec = NULL,
col_gap = 3L
)
Arguments
obj |
( |
indent_rownames |
( |
expand_newlines |
( |
indent_size |
( |
fontspec |
( |
col_gap |
( |
Details
The strings in the return object are defined as follows: row labels are those determined by make_row_df and cell
values are determined using get_formatted_cells. (Column labels are calculated using a non-exported internal
function.
Value
A list with the following elements:
stringsThe content, as it should be printed, of the top-left material, column headers, row labels, and cell values of
tt.spansThe column-span information for each print-string in the
stringsmatrix.alignsThe text alignment for each print-string in the
stringsmatrix.displayWhether each print-string in the strings matrix should be printed.
row_infoThe
data.framegenerated bymake_row_df.
With an additional nrow_header attribute indicating the number of pseudo "rows" that the column structure defines.
Examples
library(dplyr)
iris2 <- iris %>%
group_by(Species) %>%
mutate(group = as.factor(rep_len(c("a", "b"), length.out = n()))) %>%
ungroup()
lyt <- basic_table() %>%
split_cols_by("Species") %>%
split_cols_by("group") %>%
analyze(c("Sepal.Length", "Petal.Width"),
afun = list_wrap_x(summary), format = "xx.xx"
)
lyt
tbl <- build_table(lyt, iris2)
matrix_form(tbl)