Learn R Programming

rtables (version 0.6.6)

data.frame_export: Generate a Result Data Frame

Description

Collection of utilities to exctract data.frame from TableTree objects.

Usage

as_result_df(tt, spec = "v0_experimental", simplify = FALSE, ...)

result_df_specs()

path_enriched_df(tt, path_fun = collapse_path, value_fun = collapse_values)

Value

result_df_specs(): returns a named list of result data frame extraction functions by "specification".

path_enriched_df(): returns a data frame of tt's cell values (processed by value_fun, with columns named by the full column paths (processed by path_fun and an additional row_path column with the row paths (processed by by path_fun).

Arguments

tt

TableTree (or related class). A TableTree object representing a populated table.

spec

character(1). The specification to use to extract the result data frame. See details

simplify

logical(1). If TRUE, the result data frame will have only visible labels and result columns.

...

Passed to spec-specific result data frame conversion function. Currently it can be one or more of the following parameters (valid only for v0_experimental spec for now):

  • expand_colnames: when TRUE, the result data frame will have expanded column names above the usual output. This is useful when the result data frame is used for further processing.

  • simplify: when TRUE, the result data frame will have only visible labels and result columns.

  • as_strings: when TRUE, the result data frame will have all values as strings, as they appear in the final table (it can also be retrieved from matrix_form(tt)$strings). This is also true for column counts if expand_colnames = TRUE.

  • as_viewer: when TRUE, the result data frame will have all values as they appear in the final table, i.e. with the same precision and numbers, but in easy-to-use numeric form.

path_fun

function. Function to transform paths into single-string row/column names.

value_fun

function. Function to transform cell values into cells of the data.frame. Defaults to collapse_values which creates strings where multi-valued cells are collapsed together, separated by |.

Functions

  • result_df_specs(): list of functions that extract result data frames from TableTrees.

  • path_enriched_df(): transform TableTree object to Path-Enriched data.frame.

Details

as_result_df(): Result data frame specifications may differ in the exact information they include and the form in which they represent it. Specifications whose names end in "_experimental" are subject to change without notice, but specifications without the "_experimental" suffix will remain available including any bugs in their construction indefinitely.

Examples

Run this code
lyt <- basic_table() %>%
  split_cols_by("ARM") %>%
  split_rows_by("STRATA1") %>%
  analyze(c("AGE", "BMRKR2"))

tbl <- build_table(lyt, ex_adsl)
as_result_df(tbl)

result_df_specs()

lyt <- basic_table() %>%
  split_cols_by("ARM") %>%
  analyze(c("AGE", "BMRKR2"))

tbl <- build_table(lyt, ex_adsl)
path_enriched_df(tbl)

Run the code above in your browser using DataLab