Uploaded November 2024 | Updated November 2026, 2 days ago
Automation of reporting statistical results with R (mocktables, summary tables, result narrations) - Smitha Ankinakatte
Abstract: For one who works with programming, working on word documents such as creating tables, adjusting spaces, fonts seems to be tiring. In the pharma domain, statisticians are involved in one such task of building mock shells for tables and replicating the same table structure (using programming software) to report statistical results. Statisticians are also required to provide statistical narratives for key results, which involves copying numerical values from summary tables and manually crafting the narrative - another time-consuming job. Many pharmaceutical companies have developed their own R libraries, some of which are available in the public domain. However, the output formats (i.e., the class of output objects) from these libraries are often not flexible and difficult to adapt to specific end-user requirements.
This abstract proposes a solution to these challenges using R by:
1. Creating Custom R Functions (Macros) for table layout: We propose building R functions that can generate table mock shells, which can later be reused to report statistical outputs. For example, a function like `fun_demo_tab` could be used to create a mock table for demographic data to be included in a TLF (Tables, Listings, and Figures) mock shell. The same function could then be reused to present the statistical summary of demographic data in the final report.
2. Automating Statistical Narration: We suggest developing an R macro along with RMarkdown that can automatically extract numerical values from summary tables and integrate them into a predefined narrative framework. This would significantly reduce the time statisticians spend on this task, cutting it down from hours to just a few seconds.
Resources mentioned in the talk:
- {tidyverse} R packages for data science tidyverse.org
- {officer} Manipulation of Microsoft Word and PowerPoint Documents davidgohel.github.io/officer
- {flextable} Functions or tabular reporting davidgohel.github.io/flextable
Presented at the 2024 R/Pharma Conference APAC Track
Automation of reporting statistical results with R (mocktables, summary tables, result narrations) - Smitha Ankinakatte
Abstract: For one who works with programming, working on word documents such as creating tables, adjusting spaces, fonts seems to be tiring. In the pharma domain, statisticians are involved in one such task of building mock shells for tables and replicating the same table structure (using programming software) to report statistical results. Statisticians are also required to provide statistical narratives for key results, which involves copying numerical values from summary tables and manually crafting the narrative - another time-consuming job. Many pharmaceutical companies have developed their own R libraries, some of which are available in the public domain. However, the output formats (i.e., the class of output objects) from these libraries are often not flexible and difficult to adapt to specific end-user requirements.
This abstract proposes a solution to these challenges using R by:
1. Creating Custom R Functions (Macros) for table layout: We propose building R functions that can generate table mock shells, which can later be reused to report statistical outputs. For example, a function like `fun_demo_tab` could be used to create a mock table for demographic data to be included in a TLF (Tables, Listings, and Figures) mock shell. The same function could then be reused to present the statistical summary of demographic data in the final report.
2. Automating Statistical Narration: We suggest developing an R macro along with RMarkdown that can automatically extract numerical values from summary tables and integrate them into a predefined narrative framework. This would significantly reduce the time statisticians spend on this task, cutting it down from hours to just a few seconds.
Resources mentioned in the talk:
- {tidyverse} R packages for data science tidyverse.org
- {officer} Manipulation of Microsoft Word and PowerPoint Documents davidgohel.github.io/officer
- {flextable} Functions or tabular reporting davidgohel.github.io/flextable
Presented at the 2024 R/Pharma Conference APAC Track










