A Guided Tour of rtables - Advanced
Contributed by Johnson & Johnson Innovative Medicine
Gabriel Becker
Dan Hofstaedter
2025-12-27
Source:vignettes/guided_advanced.Rmd
guided_advanced.RmdScope and Audience
We saw in the previous intermediate portion of this tour
that a well engineered library of analysis, group summary, and split
functions can combine to support a massive array of different individual
tables. Whether we are tasked with maintaining and extending those
libraries or simply with creating custom tables outside of that
supported space, we sometimes need to write new custom functions. By the
end of this portion of the tour we will have the tools necessary to do
that. While gaining those tools, we will also become more familiar with
the structure of TableTree objects (how
rtables models tables) and how to interact with them once
they are created.
Upon learning the material in this portion of the training, users
will be able to fully exploit the flexibility and power of the
rtables layout and table engines to create virtually any
desired table in cases when their existing function library falls
short.
Chapters
-
Custom Analysis and Group
Summary Functions Core concepts for creating custom analysis and
group summary functions
-
Structure-Conditional
Behavior In
afuns With.spl_contextCreatingafun/cfunbehavior conditional on location within the table structure using.spl_contextand other optional arguments. -
Calling
Existing
afuns Within Customafuns Details about whatin_rowsreturns and how we can use that to wrap or combine existingafuns orcfuns -
Useful
Behavioral Building Blocks For Complex Custom
afuns Examples of prototypical behaviors which can be reused and combined when writing customafuns
-
Structure-Conditional
Behavior In
-
Custom Split
Functions Core concepts for creating custom split functions
-
Using
make_split_funEffectivelymake_split_funand recognizing when to specifypre,core, andpostbehavior customizations -
Using And Combining
Provided Behavior Building Blocks The split function behavior
building blocks provided by
rtablesand how to use and combine them - Writing Reusable Behavior Building Blocks Writing new custom split function behaviors so that they are reusable
- Some Complex Worked Examples Combining these topics to create complex custom split functions
-
Using
-
Understanding and Interacting
With
TableTreeObjects Understanding howrtablesmodels tables and how to interact with them after creation- Table Structure and Pathing Table structure and describing locations within a table via pathing (existing vignette)
- Accessing Values Within A Table Retrieving values from a table
-
Writing Custom
Scoring Functions For Sorting Writing custom scoring functions for
use with
sort_at_path -
Writing Custom
Pruning Functions Writing custom pruning functions for use with
prune_table