Package: tplyr2 0.2.0

Mike Stackhouse

tplyr2: A Grammar of Clinical Summary Tables

Implements a grammar of summary data for clinical reports. Clinical summary tables are decomposed into modular layers, each representing an independent summary block. Supports count, descriptive statistics, and shift layer types with a declarative spec-based API built on data.table for performance.

Authors:Mike Stackhouse [aut, cre]

tplyr2_0.2.0.tar.gz
tplyr2_0.2.0.zip(r-4.7-any)tplyr2_0.2.0.zip(r-4.6-any)tplyr2_0.2.0.zip(r-4.5-any)
tplyr2_0.2.0.tgz(r-4.6-any)tplyr2_0.2.0.tgz(r-4.5-any)
tplyr2_0.2.0.tar.gz(r-4.7-any)tplyr2_0.2.0.tar.gz(r-4.6-any)
tplyr2_0.2.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
tplyr2/json (API)

# Install 'tplyr2' in R:
install.packages('tplyr2', repos = c('https://atorus-research.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/atorus-research/tplyr2/issues

Pkgdown/docs site:https://atorus-research.github.io

Datasets:

On CRAN:

Conda:

7.18 score 5 stars 61 scripts 224 downloads 39 exports 11 dependencies

Last updated from:9f04a58c7e. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK152
source / vignettesOK193
linux-releaseOK142
macos-releaseOK138
macos-oldrelOK140
windows-develOK139
windows-releaseOK142
windows-oldrelOK137
wasm-releaseOK96

Exports:apply_conditional_formatapply_formatsapply_row_masksas_displayassoc_testcollapse_row_labelscustom_groupf_strgenerate_row_idsget_data_labelsgroup_analyzegroup_countgroup_descgroup_shiftis_pop_datais_tplyr_layeris_tplyr_speclabellayer_settingspop_dataproportion_cireplace_leading_whitespacestr_extract_numstr_indent_wraptotal_grouptplyr_buildtplyr_from_ardtplyr_header_ntplyr_layerstplyr_metatplyr_meta_resulttplyr_meta_subsettplyr_numeric_datatplyr_read_spectplyr_spectplyr_stats_datatplyr_to_ardtplyr_write_spectplyr2_options

Dependencies:clidata.tablegluejsonlitelifecyclemagrittrpurrrrlangstringistringrvctrs

Getting Started with tplyr2
How tplyr2 Works | The tplyr_spec() Object | The tplyr_layer() Object | Building a Table | String Formatting in tplyr2 | Layer Types | Descriptive Statistics Layers | Multiple Target Variables | Count Layers | Total Rows | Distinct Counting | Nested Counts | Shift Layers | Numeric Data | Where to Go from Here | References

Last update: 2026-08-02
Started: 2026-02-15

Clinical Display Conventions
Introduction | Small and Large Percentages | Zero Counts | Showing Only Selected Levels | Missing and Total Rows | One Statistic Per Column | Count layers: stat_columns | Descriptive layers: stats_as_columns | Shift Table Denominators | The denominator row | Indenting and Wrapping Nested Terms | Conventions a Format String Cannot Express | Getting the Table Out | Where to Go From Here

Last update: 2026-07-31
Started: 2026-07-31

Count Layers
Introduction | A Simple Count | Adding a Total Column | Custom Column Groups | Custom Format Strings | Total Rows | Population Data: Getting the Denominator Right | Distinct Versus Event Counts | Displaying Statistics in Separate Columns | A Note on Parenthesis Hugging | Nested Count Summaries | Collapsing Row Labels | Default Mode (Stub Rows) | Nest Mode | Nested Counts with Total Rows | Where to Go from Here

Last update: 2026-07-31
Started: 2026-02-15

Descriptive Statistics Layers
Introduction | Built-in Summaries | Quantile Algorithm | Custom Summaries | Layer-Level Custom Summaries | Session-Level Custom Summaries | Overriding Built-in Summaries | Multi-Variable Descriptive Statistics | Records Assessed: n Versus n_records | Statistics as Columns | Adding a Comparison p-value | Where to Go From Here

Last update: 2026-07-31
Started: 2026-02-15

Format Strings
Introduction | Seeing the alignment in this vignette | Anatomy of a Format String | Literals cannot contain x, X, a, or A | Field Width and Padding | Where Format Strings Go | Count and shift layers: the n_counts key | Descriptive statistics layers: a named list, one entry per row | Analyze layers: whatever your function returns | One format string per column: stat_columns | Statistic Keywords by Layer Type | Count and shift layers | Descriptive statistics layers | Rounding | Missing Values and the empty Argument | Formatting Numbers Outside a Layer | Where to Go From Here

Last update: 2026-07-31
Started: 2026-07-31

Metadata and Traceability
Why Traceability Matters | Building with Metadata | Row IDs | Inspecting Cell Metadata | Getting Source Data | Metadata for Count Layers | Total Rows | Metadata for Descriptive Statistics Layers | Where Filters in Metadata | Anti-Join Metadata for Missing Subjects | Stat Columns and the statistic Field | Practical Applications | Summary | See Also

Last update: 2026-07-31
Started: 2026-02-15

Post-Processing
Introduction | Building the Example Data | Row Masks | Adding Row Breaks Between Layers | Collapsing Row Labels | Extracting Numeric Values | Conditional Formatting | Replacing Leading Whitespace | Standalone Format Application | Text Wrapping | Putting It All Together | Adding Conditional Formatting to the Pipeline | Collapsing In Place (Nest Mode) | The Final Step: as_display() | Summary

Last update: 2026-07-31
Started: 2026-02-15

Precision and Alignment
Introduction | Auto-Precision | The +N offset | precision_on: measuring a different variable | precision_by: one width per group | Capping Precision | Supplying Precision From Outside | Auto-precision is a descriptive-statistics feature | Parenthesis Hugging | Hugging is applied per group, not per side | There must be something to hug | Migrating from Tplyr v1 | Hugging with auto-precision | Putting It Together | Where to Go From Here

Last update: 2026-07-31
Started: 2026-07-31

Risk Difference
Introduction | Basic Risk Difference | Configuring Comparisons | Formatting Output | Confidence Interval Level | Risk Difference with Distinct Counts | Interaction with Special Rows | Extracting Raw Numbers | Risk Difference Versus Association Tests | Summary | Single-Level Layers Only

Last update: 2026-07-31
Started: 2026-02-15

Shift Layers
Introduction | A Basic Example | Filling Missing Groups Using Factors | Customizing the Format | Shift Denominators | The Denominator Row | Zero Cells and Percent Thresholds | Distinct (Subject-Level) Shifts | Association Tests | One Thing to Note | Where to Go From Here

Last update: 2026-07-31
Started: 2026-02-15

Sorting a tplyr2 Table
Introduction | Ordering Columns Explained | Sorting Across Layers | Sorting by Variable Values | Factor Level Ordering | VARN Companion Column Ordering | Sorting Descriptive Statistics | Sorting Count Layers | Sorting by Count | Nested Count Sorting | Sorting Preferred Terms by Frequency | Practical Example: Preparing a Final Table

Last update: 2026-07-31
Started: 2026-02-15

Table Properties
Introduction | Column Variables | Multiple Column Variables | Table-Level Filtering with where | Treatment Groups | Total Groups | Custom Groups | Combining Total and Custom Groups | Population Data | Extracting Header N | Population Data with Filters | Data Completion | Limiting Completion with limit_data_by | Where to Go From Here

Last update: 2026-07-31
Started: 2026-02-15

tplyr2 Options
Introduction | Viewing Current Options | IBM Rounding | Quantile Algorithm | Precision Cap | Custom Summaries | Scientific Notation Control | Reading Variable Labels | Resetting Options | See Also

Last update: 2026-07-31
Started: 2026-02-15

Analysis Results Data
Introduction | Converting to ARD | ARD Structure | Count Layer ARD | Descriptive Statistics Layer ARD | Reconstructing from ARD | Verifying the Round-Trip | Use Cases | Standards-Compliant Data Exchange | Separating Computation from Presentation | Layer Coverage | Archiving and Reproducibility | Summary

Last update: 2026-07-28
Started: 2026-02-15

Building an Adverse Events Table
Introduction | The Population Principle | Step 1: Incidence by System Organ Class and Preferred Term | Step 2: "Any Adverse Event" and Subjects With No Events | Step 3: A Between-Arm Comparison | Step 4: A "Most Frequent Events" Variant, With Risk Difference | Step 5: A Display-Ready Table | See Also

Last update: 2026-07-28
Started: 2026-07-28

Comparative Statistics and Binding External Results
Where statistics come from in tplyr2 | Native comparisons across the treatment columns | Risk difference | Association tests with assoc_test() | Single-proportion confidence intervals | Bringing your own statistics | Attach a statistic as a column | Attach a statistic as a row | Missing or non-estimable results | group_analyze() for in-spec custom statistics | Handing off to a table package

Last update: 2026-07-28
Started: 2026-07-26

Custom Analysis Layers
Introduction | The analyze_fn Contract | Format Strings Mode | Multiple Statistics Per Row | Pre-Formatted Mode | Integration with by Variables | Combining with Other Layers | Error Handling | Summary | See Also

Last update: 2026-07-28
Started: 2026-02-15

Denominators
Introduction | Default Behavior | Controlling Denominator Grouping with denoms_by | Separate Denominator Populations with denom_where | Excluding Values from Denominators with denom_ignore | Denominators with Distinct Counts | Confidence Intervals for the Single Proportion | Denominators with Population Data | Missing Subjects | Putting It All Together | Summary | See Also

Last update: 2026-07-28
Started: 2026-02-15

Migrating from Tplyr v1
Introduction | Quick Reference: Function Mapping | Key Differences in Detail | Data Is Separated from Configuration | Variable Names Are Quoted Strings | Settings Are Collected in an Object | Format Strings Use Quoted Variable Names | Side-by-Side Examples | Demographics Table | Tplyr v1 | tplyr2 | Adverse Events Table (Nested Counts) | New Features in tplyr2 | Comparative and Inferential Statistics | Binding External Results and Display Helpers | Multi-Column Count Layouts | Spec Serialization | Custom Analysis Layers | Cell-Level Metadata | ARD Conversion and Numeric Data | Performance | Overall Speedup by Layer Type | Detailed Results | Count Layers | Nested Count Layers | Descriptive Statistics Layers | Shift Layers | Summary

Last update: 2026-07-28
Started: 2026-02-15

Spec Serialization
Introduction | Writing a Spec to JSON | Reading a Spec Back | YAML Format | What Gets Serialized | Expressions | Format Strings | Labels in by | Functions | Layer Settings | Examining the Serialized Output | A More Complex Example | Use Cases | Version-Controlled Table Definitions | Sharing Across Teams | Applying a Spec to Different Data | Regulatory Archival | See Also

Last update: 2026-07-28
Started: 2026-02-15

Readme and manuals

Help Manual

Help pageTopics
Conditional reformatting of a pre-populated string of numbersapply_conditional_format
Apply format strings to numeric valuesapply_formats
Apply row masks to blank repeated row labelsapply_row_masks
Extract a display-ready frame from a build resultas_display
Association-test column(s) for count, shift, and desc layersassoc_test
Collapse row labels into a single columncollapse_row_labels
Create a custom column group configurationcustom_group
Create a format string objectf_str
Generate unique row IDs for output rowsgenerate_row_ids
Extract variable labels from a data.frameget_data_labels
Create a custom analysis layergroup_analyze
Create a count layergroup_count
Create a descriptive statistics layergroup_desc
Create a shift layergroup_shift
Check if an object is a tplyr_pop_datais_pop_data
Check if an object is a tplyr_layeris_tplyr_layer
Check if an object is a tplyr_specis_tplyr_spec
Create a text label for use in by parameterslabel
Create layer settingslayer_settings
Create a population data configurationpop_data
Confidence interval for a single binomial proportionproportion_ci
Replace leading whitespace with a specified stringreplace_leading_whitespace
Extract numeric values from formatted stringsstr_extract_num
Wrap strings to a specific width with hyphenation while preserving indentationstr_indent_wrap
Create a total group configurationtotal_group
Adverse events analysis datasettplyr_adae
Laboratory data analysis datasettplyr_adlb
Subject-level analysis datasettplyr_adsl
Build a tplyr2 table from a spec and datatplyr_build
Reconstruct a formatted table from ARD and a spectplyr_from_ard
Extract header N from a tplyr2 build resulttplyr_header_n
Create a list of layerstplyr_layers
Metadata object for a tplyr output celltplyr_meta
Get metadata for a specific output celltplyr_meta_result
Get source data rows for a specific output celltplyr_meta_subset
Retrieve raw numeric data from a tplyr_build resulttplyr_numeric_data
Read a tplyr_spec from JSON or YAMLtplyr_read_spec
Create a tplyr2 table specificationtplyr_spec
Retrieve raw statistic values from a tplyr_build resulttplyr_stats_data
Convert tplyr_build output to Analysis Results Data (ARD) formattplyr_to_ard
Write a tplyr_spec to JSON or YAMLtplyr_write_spec
Get or set tplyr2 package optionstplyr2_options