to_string_matrix {tern} | R Documentation |
Convert table into matrix of strings
Description
Helper function to use mostly within tests. with_spaces
parameter allows
to test not only for content but also indentation and table structure.
print_txt_to_copy
instead facilitate the testing development by returning a well
formatted text that needs only to be copied and pasted in the expected output.
Usage
to_string_matrix(
x,
widths = NULL,
max_width = NULL,
hsep = formatters::default_hsep(),
with_spaces = TRUE,
print_txt_to_copy = FALSE
)
Arguments
x |
( |
widths |
( |
max_width |
( |
hsep |
( |
with_spaces |
( |
print_txt_to_copy |
( |
Value
A matrix
of string
s. If print_txt_to_copy = TRUE
the well formatted printout of the
table will be printed to console, ready to be copied as a expected value.
Examples
tbl <- basic_table() %>%
split_rows_by("SEX") %>%
split_cols_by("ARM") %>%
analyze("AGE") %>%
build_table(tern_ex_adsl)
to_string_matrix(tbl, widths = ceiling(propose_column_widths(tbl) / 2))