How ddsjoberg/gtsummary works
Project Type and Scope
• This is a full-fledged R package. Its core value is providing a high-level API for summarizing data frames and regression models.
• Its modules cover data processing, table creation, styling modifications, and exporting or rendering of tables using different output engines (e.g., {gt}, kable, or as a tibble).
Break Down the File Structure into Major Components
• Source Code (R/ folder): Contains the bulk of the implementation. Nearly every R function is split by its role—from adding statistical info (e.g., add_p, add_ci, add_difference) to formatting (modify_caption, style_pvalue) and output conversion (as_gt, as_kable, as_tibble).
• Documentation & Man Pages (man/ folder and README/vignettes): Provide detailed user guidance, function documentation, and examples.
• Testing (tests/ folder): Contains unit tests that validate each function and overall integrity. This folder shows that the package emphasizes reliability.
• Continuous Integration/Workflow (/.github/workflows): Automated checks (e.g., R-CMD-check, pkgdown builds, code coverage) to ensure consistent quality integration.
• Package Metadata and Configuration: Files like DESCRIPTION, NAMESPACE, LICENSE, and pkgdown configuration files define package metadata, export functions, licensing, and documentation site building.
• Additional Resources: Data examples (data-raw/) and project vignettes (vignettes/) for extended examples and interactive demonstrations.
Main Components
– API / User Interface Layer:
• Represents the functions as exposed to users (e.g., tbl_summary, tbl_regression, tbl_merge).
• How these functions provide entry points to the package.
– Core Processing Modules:
• Implementation of core functions split by functionality such as:
◦ Data Summarization: Function files handling tbl_summary construction.
◦ Regression Handling: Modules for tbl_regression and related statistical outputs.
◦ Table Manipulation & Formatting: Files for modifying, styling, merging, and stacking tables.
◦ Helper Functions: Utility files (e.g., inline_text, select_helpers) that support the core functions.
– Output Conversion / Rendering Layer:
– External Dependencies:
• Interactions with external packages such as broom (for tidying up model outputs), gt (for table styling/rendering), and labelled.
– Testing and Validation:
• Encompass the tests which ensure each module’s functioning. This reassures the integrity of data transformation and output.
– Continuous Integration & Documentation:
• That CI workflows (GitHub Actions) and documentation tools (like pkgdown) are part of the system, ensuring that updates and changes pass necessary checks before deployment.
Relationships and Data Flow
– Show how data flows from raw inputs through transformation functions, then into formatting/conversion layers before output.
– Represent configuration and documentation generation as side processes that consume the source code information to generate man pages and website documentation.