
rtable
to a list of matrices which can be used for outputtingAlthough 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.
# S4 method for VTableTree
matrix_form(
obj,
indent_rownames = FALSE,
expand_newlines = TRUE,
indent_size = 2,
fontspec = NULL,
col_gap = 3L,
round_type = c("iec", "sas")
)
A list with the following elements:
strings
The content, as it should be printed, of the top-left material, column headers, row labels,
and cell values of tt
.
spans
The column-span information for each print-string in the strings
matrix.
aligns
The text alignment for each print-string in the strings
matrix.
display
Whether each print-string in the strings matrix should be printed.
row_info
The data.frame
generated by make_row_df
.
With an additional nrow_header
attribute indicating the number of pseudo "rows" that the column structure defines.
(ANY
)
the object for the accessor to access or modify.
(flag
)
if TRUE
, the column with the row names in the strings
matrix of the output
has indented row names (strings pre-fixed).
(flag
)
whether the matrix form generated should expand rows whose values contain
newlines into multiple 'physical' rows (as they will appear when rendered into ASCII). Defaults to TRUE
.
(numeric(1)
)
number of spaces to use per indent level. Defaults to 2.
(font_spec
)
The font that should be used by default when
rendering this MatrixPrintForm
object, or NULL (the default).
(numeric(1)
)]
The number of spaces (in the font specified
by fontspec
) that should be placed between columns when the table
is rendered directly to text (e.g., by toString
or export_as_txt
). Defaults
to 3
.
("iec"
or "sas"
)
the type of rounding to perform. iec,
the default, peforms rounding compliant with IEC 60559 (see details), while
sas performs nearest-value rounding consistent with rounding within SAS.
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.
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)
Run the code above in your browser using DataLab