• Stars
    star
    201
  • Rank 188,773 (Top 4 %)
  • Language
    R
  • License
    Other
  • Created over 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Reporting tables with R

rtables

Check πŸ›  Docs πŸ“š Code Coverage πŸ“”

GitHub forks GitHub Repo stars

GitHub commit activity GitHub contributors GitHub last commit GitHub pull requests GitHub repo size GitHub language count Project Status: Active – The project has reached a stable, usable state and is being actively developed. Open Issues

CRAN Version Current Version

Reporting tables with R

The rtables R package was designed to create and display complex tables with R. The cells in an rtable may contain any high-dimensional data structure which can then be displayed with cell-specific formatting instructions. Currently, rtables can be outputted in ascii html, and pdf, as well powerpoint (via conversion to flextable objects). rtf support is in development and will be in a future release.

rtables is developed and copy written by F. Hoffmann-La Roche and it is released open source under Apache License Version 2.

rtables development is driven by the need to create regulatory ready tables for health authority review. Some of the key requirements for this undertaking are listed below:

  • cell values and their visualization separate (i.e.Β no string based tables)
    • values need to be programmatically accessible in their non-rounded state for cross-checking
  • multiple values displayed within a cell
  • flexible tabulation framework
  • flexible formatting (cell spans, rounding, alignment, etc.)
  • multiple output formats (html, ascii, latex, pdf, xml)
  • flexible pagination in both horizontal and vertical directions
  • distinguish between name and label in the data structure to work with CDISC standards
  • title, footnotes, cell cell/row/column references

rtables currently covers virtually all of these requirements, and further advances remain under active development.

Installation

rtables is available on CRAN and you can install the latest released version with:

install.packages("rtables")

or you can install the latest development version directly from GitHub with:

remotes::install_github("insightsengineering/formatters")
remotes::install_github("insightsengineering/rtables")

Note you might need to set your GITHUB_PAT environment variable in order to be able to install from GitHub.

Packaged releases (both those on CRAN and those between official CRAN releases) can be found in the releases list.

Usage

We first demonstrate with a demographic table-like example and then show the creation of a more complex table.

library(rtables)

lyt <- basic_table() %>%
  split_cols_by("ARM") %>%
  analyze(c("AGE", "BMRKR1", "BMRKR2"), function(x, ...) {
    if (is.numeric(x)) {
      in_rows(
        "Mean (sd)" = c(mean(x), sd(x)),
        "Median" = median(x),
        "Min - Max" = range(x),
        .formats = c("xx.xx (xx.xx)", "xx.xx", "xx.xx - xx.xx")
      )
    } else if (is.factor(x) || is.character(x)) {
      in_rows(.list = list_wrap_x(table)(x))
    } else {
      stop("type not supported")
    }
  })

build_table(lyt, ex_adsl)
#>                 A: Drug X      B: Placebo     C: Combination
#> β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
#> AGE                                                         
#>   Mean (sd)   33.77 (6.55)    35.43 (7.90)     35.43 (7.72) 
#>   Median          33.00           35.00           35.00     
#>   Min - Max   21.00 - 50.00   21.00 - 62.00   20.00 - 69.00 
#> BMRKR1                                                      
#>   Mean (sd)    5.97 (3.55)     5.70 (3.31)     5.62 (3.49)  
#>   Median          5.39            4.81             4.61     
#>   Min - Max   0.41 - 17.67    0.65 - 14.24     0.17 - 21.39 
#> BMRKR2                                                      
#>   LOW              50              45               40      
#>   MEDIUM           37              56               42      
#>   HIGH             47              33               50
library(rtables)
library(dplyr)

## for simplicity grab non-sparse subset
ADSL <- ex_adsl %>% filter(RACE %in% levels(RACE)[1:3])

biomarker_ave <- function(x, ...) {
     val <- if(length(x) > 0) round(mean(x), 2) else "no data"
     in_rows(
        "Biomarker 1 (mean)" = rcell(val)
     )
}

basic_table(show_colcounts = TRUE) %>%
  split_cols_by("ARM") %>%
  split_cols_by("BMRKR2") %>%
  split_rows_by("RACE", split_fun = trim_levels_in_group("SEX")) %>%
  split_rows_by("SEX") %>%
  summarize_row_groups() %>%
  analyze("BMRKR1", biomarker_ave) %>%
  build_table(ADSL)
#>                                          A: Drug X                            B: Placebo                           C: Combination           
#>                                LOW        MEDIUM        HIGH         LOW         MEDIUM       HIGH         LOW         MEDIUM        HIGH   
#>                               (N=45)      (N=35)       (N=46)       (N=42)       (N=48)      (N=31)       (N=40)       (N=39)       (N=47)  
#> β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
#> ASIAN                                                                                                                                       
#>   F                         13 (28.9%)   9 (25.7%)   19 (41.3%)   9 (21.4%)    18 (37.5%)   9 (29.0%)   13 (32.5%)   9 (23.1%)    17 (36.2%)
#>     Biomarker 1 (mean)         5.23        6.17         5.38         5.64         5.55        4.33         5.46         5.48         5.19   
#>   M                         8 (17.8%)    7 (20.0%)   10 (21.7%)   12 (28.6%)   10 (20.8%)   8 (25.8%)   5 (12.5%)    11 (28.2%)   16 (34.0%)
#>     Biomarker 1 (mean)         6.77        6.06         5.54         4.9          4.98        6.81         6.53         5.47         4.98   
#>   U                          1 (2.2%)    1 (2.9%)     0 (0.0%)     0 (0.0%)     0 (0.0%)    1 (3.2%)     0 (0.0%)     1 (2.6%)     1 (2.1%) 
#>     Biomarker 1 (mean)         4.68         7.7       no data      no data      no data       6.97       no data       11.93         9.01   
#> BLACK OR AFRICAN AMERICAN                                                                                                                   
#>   F                         6 (13.3%)    3 (8.6%)    9 (19.6%)    6 (14.3%)    8 (16.7%)    2 (6.5%)    7 (17.5%)    4 (10.3%)     3 (6.4%) 
#>     Biomarker 1 (mean)         5.01         7.2         6.79         6.15         5.26        8.57         5.72         5.76         4.58   
#>   M                         5 (11.1%)    5 (14.3%)    2 (4.3%)     3 (7.1%)    5 (10.4%)    4 (12.9%)   4 (10.0%)    5 (12.8%)    5 (10.6%) 
#>     Biomarker 1 (mean)         6.92        5.82        11.66         4.46         6.14        8.47         6.16         5.25         4.83   
#>   U                          0 (0.0%)    0 (0.0%)     0 (0.0%)     0 (0.0%)     0 (0.0%)    0 (0.0%)     1 (2.5%)     1 (2.6%)     0 (0.0%) 
#>     Biomarker 1 (mean)       no data      no data     no data      no data      no data      no data       2.79         9.82       no data  
#>   UNDIFFERENTIATED           1 (2.2%)    0 (0.0%)     0 (0.0%)     0 (0.0%)     0 (0.0%)    0 (0.0%)     2 (5.0%)     0 (0.0%)     0 (0.0%) 
#>     Biomarker 1 (mean)         9.48       no data     no data      no data      no data      no data       6.46       no data      no data  
#> WHITE                                                                                                                                       
#>   F                         6 (13.3%)    7 (20.0%)    4 (8.7%)    5 (11.9%)    6 (12.5%)    6 (19.4%)   6 (15.0%)     3 (7.7%)     2 (4.3%) 
#>     Biomarker 1 (mean)         4.43        7.83         4.52         6.42         5.07        7.83         6.71         5.87         10.7   
#>   M                          4 (8.9%)    3 (8.6%)     2 (4.3%)    6 (14.3%)     1 (2.1%)    1 (3.2%)     2 (5.0%)    5 (12.8%)     3 (6.4%) 
#>     Biomarker 1 (mean)         5.81        7.23         1.39         4.72         4.58        12.87        2.3          5.1          5.98   
#>   U                          1 (2.2%)    0 (0.0%)     0 (0.0%)     1 (2.4%)     0 (0.0%)    0 (0.0%)     0 (0.0%)     0 (0.0%)     0 (0.0%) 
#>     Biomarker 1 (mean)         3.94       no data     no data        3.77       no data      no data     no data      no data      no data

Acknowledgments

We would like to thank everyone who has made rtables a better project by providing feedback and improving examples & vignettes. The following list of contributors is alphabetical:

Maximo Carreras, Francois Collins, Saibah Chohan, Tadeusz Lewandowski, Nick Paszty, Nina Qi, Jana Stoilova, Heng Wang, Godwin Yung

Presentations

Advanced rtables Training

  • Part 1 Slides
  • Part 2 - Forthcoming

RinPharma Workshop: Creating Submission-Quality Clinical Trial Reporting Tables in R with rtables

R Adoption Series

New (Current) Layouting and Tabulation Framework (v.0.3+)

More Repositories

1

teal

Exploratory Web Apps for Analyzing Clinical Trial Data
R
159
star
2

tern

Table, Listings, and Graphs (TLG) library for common outputs used in clinical trials
R
67
star
3

thevalidatoR

Github Action that generates R Package Validation documentation 🏁
R
51
star
4

teal.modules.clinical

Provides teal modules for the standard clinical trials outputs
R
27
star
5

random.cdisc.data

Create random CDISC data
R
26
star
6

r.pkg.template

An opinionated R package template with CI/CD built-in
Shell
21
star
7

teal.gallery

A Gallery of Exploratory Web Apps used for Analyzing Clinical Trial Data
R
21
star
8

rlistings

Value formatting and ASCII rendering infrastructure for tables and listings.
R
16
star
9

tlg-catalog

A catalog of Tables, Listings and Graphs (TLGs) created with NEST R packages
R
15
star
10

rbmi

Reference based multiple imputation R package
R
13
star
11

sasr

sasr
R
13
star
12

formatters

A framework for creating listings of raw data that include specialized formatting, headers, footers, referential footnotes, and pagination.
R
13
star
13

cards

CDISC Analysis Results Data
R
12
star
14

scda

Access Synthetic CDISC Data from Archive Packages
R
12
star
15

JointSurvivalModels.jl

Julia implementation of joint models combining longitudinal and survival endpoints
Julia
12
star
16

hermes

Preprocessing, analyzing, and reporting of RNA-seq data
R
11
star
17

teal.slice

Reproducible slice module for teal applications
R
11
star
18

ci-images

Insights Engineering Container Images
R
10
star
19

simIDM

Simulation Engine for Multistate Models
R
10
star
20

teal.modules.general

General Purpose Teal Modules
R
9
star
21

teal.code

Code storage and execution class for teal applications
R
9
star
22

tern.gee

Create TLGs using Generalized Estimating Equations (GEE)
R
8
star
23

scda.2022

An archive of synthetic CDISC data for 2022
R
8
star
24

hex-stickers

hex sticker archive
R
8
star
25

teal.modules.hermes

RNA-seq analysis modules to add to a teal application
R
7
star
26

teal.reporter

Create and preview reports with Shiny modules
R
7
star
27

teal.data

Data model for teal applications
R
7
star
28

tern.mmrm

Create MMRM TLGs using lme4 and tern
R
6
star
29

coverage-action

Github Action that generates a coverage summary using a Cobertura XML report
6
star
30

biomarker-catalog

Biomarker Analysis Templates of Tables And Graphs πŸ“Š
SCSS
5
star
31

ggplot2.utils

Utilities, in particular geoms and stats, for use with ggplot2
R
5
star
32

teal.osprey

Community efforts to collect teal modules for TLGs defined in the osprey package
R
5
star
33

nestcolor

Package managing visual conventions of NEST graphs
R
5
star
34

goshawk

Functions that plot and summarize biomarkers/labs of interest
R
5
star
35

r-spellcheck-action

Github Action that performs a spell check on an R package
R
4
star
36

teal.logger

Logging setup for the teal family of packages
R
4
star
37

uniCATE

Univariate conditional average treatment effect estimation for predictive biomarker discovery
R
4
star
38

presidio-cli

CLI tool that analyze Text for PII Entities with Microsoft Presidio framework.
Python
4
star
39

osprey

Community effort to collect TLG code and create a catalogue
R
4
star
40

scda.2021

An archive of synthetic CDISC data for 2021
R
3
star
41

depository

A depository for previously released R packages stemming from this organization.
HTML
3
star
42

staged-dependencies-action

Github Action to implement R development stages for package development
R
3
star
43

teal.widgets

shiny widgets for teal applications
R
3
star
44

bioc-check-action

Github Action that runs Bioconductor-specific R package checks with BiocCheck.
R
3
star
45

teal.goshawk

Modules that produce web interfaces through which longitudinal visualizations can be dynamically
R
3
star
46

tern.rbmi

Create TLGs using rbmi and tern
R
3
star
47

unihtee

Tools for uncovering treatment effect modifiers in high-dimensional data.
R
3
star
48

teal.transform

Reproducible transform and merge module for teal applications
R
3
star
49

r-license-report

Github Action to generate an R Package Dependencies' License Report
R
2
star
50

nesttemplate

pkgdown template for NEST packages
JavaScript
2
star
51

presidio-action

Github Action that analyze Text for PII Entities with Microsoft Presidio framework.
2
star
52

framework-scientific-apps

AMIA 2021 - Case study in the development of a framework for quality and reproducibility in inner-sourced packages and self-service analytic dashboards
TeX
2
star
53

bsafe

TBD
R
1
star
54

codecollaboration

HTML
1
star
55

teal.modules.bsafe

Teal modules for bsafe
R
1
star
56

covtracer-action

Github Action based on the Covtracer R package
R
1
star
57

verdepcheck

An R package that tests your R package against the min/max versions of specified dependencies
R
1
star
58

r-verdepcheck-action

Github Action to check if R package works correctly with minimum version of dependencies installed
R
1
star
59

r-pkgdown-multiversion

Github Action to generate multiple versions of pkgdown docs for R packages
R
1
star