Package: rtables 0.6.9

Joe Zhu

rtables:Reporting Tables

Reporting tables often have structure that goes beyond simple rectangular data. The 'rtables' package provides a framework for declaring complex multi-level tabulations and then applying them to data. This framework models both tabulation and the resulting tables as hierarchical, tree-like objects which support sibling sub-tables, arbitrary splitting or grouping of data in row and column dimensions, cells containing multiple values, and the concept of contextual summary computations. A convenient pipe-able interface is provided for declaring table layouts and the corresponding computations, and then applying them to data.

Authors:Gabriel Becker [aut], Adrian Waddell [aut], Daniel Sabanés Bové [ctb], Maximilian Mordig [ctb], Davide Garolini [ctb], Emily de la Rua [ctb], Abinaya Yogasekaram [ctb], Joe Zhu [ctb, cre], F. Hoffmann-La Roche AG [cph, fnd]

rtables_0.6.9.tar.gz
rtables_0.6.9.tar.gz(r-4.5-noble)rtables_0.6.9.tar.gz(r-4.4-noble)
rtables_0.6.9.tgz(r-4.4-emscripten)rtables_0.6.9.tgz(r-4.3-emscripten)
rtables.pdf |rtables.html
rtables/json (API)
NEWS

# Installrtables in R:
install.packages('rtables',repos = c('https://cran.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/insightsengineering/rtables/issues

225 exports 2.76 score 13 dependencies 13 dependents 1.2k downloads

Last updated 8 days agofrom:d58476b69a

Exports:.add_row_summary.tablerowadd_colcountsadd_combo_facetadd_combo_levelsadd_existing_tableadd_overall_coladd_overall_facetadd_overall_leveladd_to_split_resultall_zeroall_zero_or_naanalyzeanalyze_colvarsAnalyzeColVarSplitAnalyzeMultiVarsAnalyzeVarSplitappend_topleftas_htmlas_result_dfassert_valid_tablebasic_tablebuild_tablecbind_rtablescell_footnotescell_footnotes<-cell_valuesCellValueclayoutclayout<-clear_indent_modscol_countscol_counts<-col_exprscol_fnotes_herecol_fnotes_here<-col_footnotescol_footnotes<-col_infocol_info<-col_pathscol_paths_summarycol_totalcol_total<-colcount_formatcolcount_format<-colcount_na_strcolcount_na_str<-colcount_visiblecolcount_visible<-collect_leavescoltreecoltree_structurecompare_rtablescont_n_allcolscont_n_onecolcontent_all_zeros_nascontent_tablecontent_table<-ContentRowcounts_wpctsDataRowdf_to_ttdo_base_splitdrop_and_remove_levelsdrop_facet_levelsdrop_split_levelsElementaryTableEmptyColInfoEmptyElTableexport_as_docxexport_as_pdfexport_as_tsvexport_as_txtfacet_colcountfacet_colcount<-facet_colcounts_visible<-find_degen_structfnotes_at_path<-format_rcellget_formatted_cellsheadheader_section_divheader_section_div<-horizontal_sephorizontal_sep<-import_from_tsvin_rowsindentindent_modindent_mod<-indent_stringinsert_row_at_pathinsert_rrowInstantiatedColumnInfois_rtablekeep_split_levelslabel_at_pathlabel_at_path<-LabelRowlist_wrap_dflist_wrap_xlow_obs_prunermain_footermain_footer<-main_titlemain_title<-make_afunmake_col_dfmake_row_dfmake_split_funmake_split_resultmanual_colsManualSplitmargins_landscapemargins_potraitmatrix_formMultiVarSplitncolnlinesno_colinfonon_ref_rcellnrowobj_avarobj_formatobj_format<-obj_labelobj_label<-obj_na_strobj_na_str<-obj_nameobj_name<-pag_tt_indicespaginate_tablepath_enriched_dfprov_footerprov_footer<-prune_empty_levelprune_tableprune_zeros_onlyqtableqtable_layoutrawvaluesrbindrbind2rbindl_rtablesrcellref_indexref_index<-ref_msgref_symbolref_symbol<-remove_split_levelsreorder_split_levelsresult_df_specsrheaderrm_all_colcountsrow_cellsrow_footnotesrow_footnotes<-row_pathsrow_paths_summaryrow_valuesrow_values<-row.namesrrowrrowlrtablertablelsanitize_table_structsection_divsection_div<-section_properties_landscapesection_properties_portraitselect_all_levelssimple_analysissort_at_pathspl_context_to_disp_pathspl_variablesplit_cols_bysplit_cols_by_cutfunsplit_cols_by_cutssplit_cols_by_multivarsplit_cols_by_quartilessplit_rows_bysplit_rows_by_cutfunsplit_rows_by_cutssplit_rows_by_multivarsplit_rows_by_quartilesstrsubtitlessubtitles<-summarize_row_groupstable_insettable_inset<-table_shelltable_shell_strtable_structureTableTreetailtheme_docx_defaulttop_lefttop_left<-top_level_section_divtop_level_section_div<-toStringtree_childrentree_children<-trim_levels_in_facetstrim_levels_in_grouptrim_levels_to_maptrim_rowstt_at_pathtt_at_path<-tt_to_flextableupdate_ref_indexingvalidate_table_structvalue_atvalue_formatsvalue_namesVarDynCutSplitVarLevelSplitVarLevWBaselineSplitvars_in_layoutViewer

Dependencies:backportsbase64enccheckmateclidigestfastmapformattersgluehtmltoolslifecyclemagrittrrlangstringi

{rtables} Advanced Usage

Rendered fromadvanced_usage.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-12-09
Started: 2023-03-02

Column Counts and Formats

Rendered fromcol_counts.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2024-06-28
Started: 2024-06-21

Comparing Against Baselines or Control

Rendered frombaseline.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-12-09
Started: 2021-01-22

Comparison with dplyr Tabulation

Rendered fromtabulation_dplyr.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2024-06-21
Started: 2021-01-22

Constructing rtables Manually

Rendered frommanual_table_construction.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-08-30
Started: 2021-01-22

Controlling Splitting Behavior

Rendered fromsplit_functions.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-12-09
Started: 2023-03-02

Customizing Appearance

Rendered fromcustom_appearance.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2024-04-16
Started: 2023-03-02

Example Clinical Trials Tables

Rendered fromclinical_trials.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2024-06-21
Started: 2021-01-22

Example Complex Analysis Function: Modelling Cox Regression

Rendered fromexample_analysis_coxreg.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-12-09
Started: 2023-08-30

Exploratory Analysis

Rendered fromexploratory_analysis.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2024-06-21
Started: 2023-08-30

Format Precedence and NA Handling

Rendered fromformat_precedence.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-08-30
Started: 2023-03-02

Introduction to {rtables}

Rendered fromintroduction.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2024-06-28
Started: 2021-01-22

Introspecting Tables

Rendered fromintrospecting_tables.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2024-06-28
Started: 2023-12-09

Pruning and Sorting Tables

Rendered fromsorting_pruning.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-12-09
Started: 2021-01-22

Subsetting and Manipulating Table Contents

Rendered fromsubsetting_tables.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2024-06-21
Started: 2021-01-22

Tabulation Concepts

Rendered fromtabulation_concepts.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-12-09
Started: 2021-01-22

Titles, Footers, and Referential Footnotes

Rendered fromtitle_footer.Rmdusingknitr::rmarkdownon Jun 28 2024.

Last update: 2023-12-09
Started: 2023-03-02

Readme and manuals

Help Manual

Help pageTopics
Add the column population counts to the headeradd_colcounts
Add a combination facet in post-processingadd_combo_facet add_overall_facet
Add an already calculated table to the layoutadd_existing_table
Add overall columnadd_overall_col
Add a virtual "overall" level to splitadd_overall_level
Additional parameters within analysis and content functions ('afun'/'cfun')additional_fun_params
Trimming and pruning criteriaall_zero all_zero_or_na content_all_zeros_nas low_obs_pruner prune_empty_level prune_zeros_only
Generate rows analyzing variables across columnsanalyze
Generate rows analyzing different variables across columnsanalyze_colvars
Define a subset tabulation/analysisAnalyzeColVarSplit AnalyzeMultiVars AnalyzeVarSplit
Append a description to the 'top-left' materials for the layoutappend_topleft
Convert an 'rtable' object to a 'shiny.tag' HTML objectas_html
Convert to a vectoras.vector,VTableTree-method asvec
Layout with 1 column and zero rowsbasic_table
Retrieve and assign elements of a 'TableTree'brackets [,VTableTree,logical,logical-method [<-,VTableTree,ANY,ANY,list-method
Create a table from a layout and databuild_table
Column-bind two 'TableTree' objectscbind_rtables
Retrieve cell values by row and column pathcell_values value_at value_at,VTableTree-method
Constructor for Cell ValueCellValue
Column information/structure accessorsclayout clayout,ANY-method clayout,PreDataTableLayouts-method clayout,VTableNodeInfo-method clayout<- clayout<-,PreDataTableLayouts-method coltree coltree,InstantiatedColumnInfo-method coltree,LayoutColTree-method coltree,PreDataColLayout-method coltree,PreDataTableLayouts-method coltree,TableRow-method coltree,VTableTree-method col_counts col_counts,InstantiatedColumnInfo-method col_counts,VTableNodeInfo-method col_counts<- col_counts<-,InstantiatedColumnInfo-method col_counts<-,VTableNodeInfo-method col_exprs col_exprs,InstantiatedColumnInfo-method col_exprs,PreDataColLayout-method col_exprs,PreDataTableLayouts-method col_info col_info,VTableNodeInfo-method col_info<- col_info<-,ElementaryTable-method col_info<-,TableRow-method col_info<-,TableTree-method col_total col_total,InstantiatedColumnInfo-method col_total,VTableNodeInfo-method col_total<- col_total<-,InstantiatedColumnInfo-method col_total<-,VTableNodeInfo-method
Clear all indent modifiers from a tableclear_indent_mods clear_indent_mods,TableRow-method clear_indent_mods,VTableTree-method
Value and Visibility of specific column counts by pathcolcount_visible colcount_visible,InstantiatedColumnInfo-method colcount_visible,LayoutColTree-method colcount_visible,VTableTree-method colcount_visible<- colcount_visible<-,InstantiatedColumnInfo-method colcount_visible<-,LayoutColTree-method colcount_visible<-,VTableTree-method
Collect leaves of a 'TableTree'collect_leaves
Display column tree structurecoltree_structure
Compare two rtablescompare_rtables
Compatibility argument conventionscompat_args
Score functions for sorting 'TableTrees'cont_n_allcols cont_n_onecol
Retrieve or set content table from a 'TableTree'content_table content_table<-
Analysis function to count levels of a factor with percentage of the column totalcounts_wpcts
Custom split functionscustom_split_funs
Generate a result data frameas_result_df data.frame_export path_enriched_df result_df_specs
Create an 'ElementaryTable' from a 'data.frame'df_to_tt
Apply basic split (for use in custom split functions)do_base_split
Pre-processing function for use in 'make_split_fun'drop_facet_levels
'TableTree' classesElementaryTable ElementaryTable-class TableTree TableTree-class
Empty table, column, split objectsEmptyAllSplit EmptyColInfo EmptyElTable EmptyRootSplit
Export as word documentexport_as_docx margins_landscape margins_potrait section_properties_landscape section_properties_portrait
Create enriched flat value table with pathsexport_as_tsv import_from_tsv
Get or set column count for a facet in column spacefacet_colcount facet_colcount,InstantiatedColumnInfo-method facet_colcount,LayoutColLeaf-method facet_colcount,LayoutColTree-method facet_colcount,VTableTree-method facet_colcount<- facet_colcount<-,InstantiatedColumnInfo-method facet_colcount<-,LayoutColLeaf-method facet_colcount<-,LayoutColTree-method facet_colcount<-,VTableTree-method
Set visibility of column counts for a group of sibling facetsfacet_colcounts_visible<-
Find degenerate (sub)structures within a tablefind_degen_struct
Format 'rcell' objectsformat_rcell
Get formatted cellsget_cell_aligns get_cell_aligns,ElementaryTable-method get_cell_aligns,LabelRow-method get_cell_aligns,TableRow-method get_cell_aligns,TableTree-method get_formatted_cells get_formatted_cells,ElementaryTable-method get_formatted_cells,LabelRow-method get_formatted_cells,TableRow-method get_formatted_cells,TableTree-method
Head and tail methodshead head,VTableTree-method tail tail,VTableTree-method
Access or recursively set header-body separator for tableshorizontal_sep horizontal_sep,VTableTree-method horizontal_sep<- horizontal_sep<-,TableRow-method horizontal_sep<-,VTableTree-method
Create multiple rows in analysis or summary functionsin_rows
Change indentation of all 'rrows' in an 'rtable'indent
Indent stringsindent_string
Insert row at pathinsert_row_at_path insert_row_at_path,VTableTree,ANY-method insert_row_at_path,VTableTree,DataRow-method
Insert 'rrow's at (before) a specific locationinsert_rrow
Instantiated column infoInstantiatedColumnInfo InstantiatedColumnInfo-class
Check if an object is a valid 'rtable'is_rtable
Label at pathlabel_at_path label_at_path<-
Row classes and constructors.tablerow ContentRow ContentRow-class DataRow DataRow-class LabelRow LabelRow-class
Length of a Cell valuelength,CellValue-method
Returns a function that coerces the return values of a function to a listlist_wrap_df list_wrap_x
Create a custom analysis function wrapping an existing functionmake_afun
Column layout summarymake_col_df
Create a custom splitting functionmake_split_fun
Construct split result objectadd_to_split_result make_split_result
Manual column declarationmanual_cols
Manually defined splitManualSplit
Transform an 'rtable' to a list of matrices which can be used for outputtingmatrix_form,VTableTree-method
Split between two or more different variablesMultiVarSplit
Names of a 'TableTree'names,InstantiatedColumnInfo-method names,LayoutColTree-method names,VTableNodeInfo-method row.names,VTableTree-method
Exported for use in 'tern'no_colinfo no_colinfo,InstantiatedColumnInfo-method no_colinfo,VTableNodeInfo-method
Table dimensionsdim,VTableNodeInfo-method ncol,VTableNodeInfo-method nrow,VTableTree-method
Row attribute accessorsobj_avar obj_avar,ElementaryTable-method obj_avar,TableRow-method row_cells row_cells,TableRow-method row_cells<- row_cells<-,TableRow-method row_values row_values,TableRow-method row_values<- row_values<-,LabelRow-method row_values<-,TableRow-method
Methods for generics in the 'formatters' packageformatters_methods main_footer,TableRow-method main_footer,VTitleFooter-method main_footer<-,VTitleFooter-method main_title,TableRow-method main_title,VTitleFooter-method main_title<-,VTitleFooter-method make_row_df,LabelRow-method make_row_df,TableRow-method make_row_df,VTableTree-method nlines,InstantiatedColumnInfo-method nlines,LabelRow-method nlines,RefFootnote-method nlines,TableRow-method obj_format,CellValue-method obj_format,Split-method obj_format,VTableNodeInfo-method obj_format<-,CellValue-method obj_format<-,Split-method obj_format<-,VTableNodeInfo-method obj_label,Split-method obj_label,TableRow-method obj_label,ValueWrapper-method obj_label,VTableTree-method obj_label<-,Split-method obj_label<-,TableRow-method obj_label<-,ValueWrapper-method obj_label<-,VTableTree-method obj_name,Split-method obj_name,VNodeInfo-method obj_name<-,Split-method obj_name<-,VNodeInfo-method obj_na_str,Split-method prov_footer,TableRow-method prov_footer,VTitleFooter-method prov_footer<-,VTitleFooter-method subtitles,TableRow-method subtitles,VTitleFooter-method subtitles<-,VTitleFooter-method table_inset,PreDataTableLayouts-method table_inset,VTableNodeInfo-method table_inset<-,InstantiatedColumnInfo-method table_inset<-,PreDataTableLayouts-method table_inset<-,VTableNodeInfo-method
Pagination of a 'TableTree'paginate_table pag_tt_indices
Recursively prune a 'TableTree'prune_table
Generalized frequency tableqtable qtable_layout
Row-bind 'TableTree' and related objectsrbind rbind,VTableNodeInfo-method rbind2,VTableNodeInfo,ANY-method rbindl_rtables
Cell value constructorsnon_ref_rcell rcell
Create a headerrheader
Set all column counts at all levels of nesting to NArm_all_colcounts rm_all_colcounts,InstantiatedColumnInfo-method rm_all_colcounts,LayoutColLeaf-method rm_all_colcounts,LayoutColTree-method rm_all_colcounts,VTableTree-method
Referential footnote accessorscell_footnotes cell_footnotes<- col_fnotes_here col_fnotes_here,ANY-method col_fnotes_here<- col_footnotes col_footnotes<- fnotes_at_path<- ref_index ref_index<- ref_msg ref_symbol ref_symbol<- row_footnotes row_footnotes<-
Get a list of table row/column pathscol_paths row_paths
Print row/column paths summarycol_paths_summary row_paths_summary
Create an 'rtable' rowrrow
Create an 'rtable' row from a vector or list of valuesrrowl
Create a tablertable rtablel
Sanitize degenerate table structuressanitize_table_struct
Section dividers accessor and setterheader_section_div header_section_div,PreDataTableLayouts-method header_section_div,VTableTree-method header_section_div<- header_section_div<-,PreDataTableLayouts-method header_section_div<-,VTableTree-method section_div section_div,list-method section_div,TableRow-method section_div,VTableTree-method section_div<- section_div<-,LabelRow-method section_div<-,list-method section_div<-,TableRow-method section_div<-,VTableTree-method top_level_section_div top_level_section_div,PreDataTableLayouts-method top_level_section_div<- top_level_section_div<-,PreDataTableLayouts-method
Add combination levels to splitadd_combo_levels select_all_levels
Split function argument conventionssf_args
Default tabulationsimple_analysis simple_analysis,ANY-method simple_analysis,factor-method simple_analysis,logical-method simple_analysis,numeric-method
Sorting a table at a specific pathsort_at_path
.spl_context within analysis and split functionsspl_context
Translate spl_context to a path to display in error messagesspl_context_to_disp_path
Variable associated with a splitspl_variable spl_variable,Split-method spl_variable,VarDynCutSplit-method spl_variable,VarLevelSplit-method spl_variable,VarStaticCutSplit-method
Declaring a column-split based on levels of a variablesplit_cols_by
Split on static or dynamic cuts of the datasplit_cols_by_cutfun split_cols_by_cuts split_cols_by_quartiles split_rows_by_cutfun split_rows_by_cuts split_rows_by_quartiles
Associate multiple variables with columnssplit_cols_by_multivar
Split functionsdrop_and_remove_levels drop_split_levels keep_split_levels remove_split_levels reorder_split_levels split_funcs trim_levels_in_group
Add rows according to levels of a variablesplit_rows_by
Associate multiple variables with rowssplit_rows_by_multivar
Add a content row of summary countssummarize_row_groups
Table shellstable_shell table_shell_str
Summarize tabletable_structure
Top left materialtop_left top_left,InstantiatedColumnInfo-method top_left,PreDataTableLayouts-method top_left,VTableTree-method top_left<- top_left<-,InstantiatedColumnInfo-method top_left<-,PreDataTableLayouts-method top_left<-,VTableTree-method
Convert an 'rtable' object to a stringtostring toString,VTableTree-method
Retrieve or set the direct children of a tree-style objecttree_children tree_children<-
Trim levels of another variable from each facet (post-processing split step)trim_levels_in_facets
Trim levels to maptrim_levels_to_map
Trim rows from a populated table without regard for table structuretrim_rows
Access or set table elements at specified pathtt_at_path tt_at_path<-
Create a 'flextable' from an 'rtables' tabletheme_docx_default tt_to_flextable
Update footnote indices on a built tableupdate_ref_indexing
Validate and assert valid table structureassert_valid_table validate_table_struct
Value formatsvalue_formats value_formats,ANY-method value_formats,LabelRow-method value_formats,TableRow-method value_formats,VTableTree-method
Split on levels within a variableVarLevelSplit VarLevelSplit-class VarLevWBaselineSplit
List variables required by a pre-data table layoutvars_in_layout vars_in_layout,CompoundSplit-method vars_in_layout,ManualSplit-method vars_in_layout,PreDataAxisLayout-method vars_in_layout,PreDataTableLayouts-method vars_in_layout,Split-method vars_in_layout,SplitVector-method
Splits for cutting by values of a numeric variableCumulativeCutSplit-class make_static_cut_split VarDynCutSplit VarDynCutSplit-class VarStaticCutSplit-class
Display an 'rtable' object in the Viewer pane in RStudio or in a browserViewer