Chapter 1 About

You are currently reading version 1.0 of the book whose URL is

The future version named dev version, currently being prepared, is available at the URL

1.1 Introduction

In this book we present various aspects of creating tables with the R language (R Core Team 2023) to analyze and report clinical trials data. The book was initiated by the R Consortium working group R Tables for Regulatory Submissions (RTRS). For a list of contributors to this book, see Appendix A.

The RTRS includes representation from several large pharmaceutical companies and contract research organizations. The goal of the working group is to create standards for creating tables that meet the requirements of FDA submission documents, and hence enhance the suitability of R for FDA submissions. It is part of a larger R Consortium effort to facilitate the certification and validation of R packages and tools for FDA submissions thereby allowing drug developers to submit documentation for regulatory approval using the R programming environment in conjunction with open-source packages without the need for closed and often expensive proprietary tools. For more information on the R Consortium see

1.2 Call for Contributions

The content of this book is intended to grow via community contribution, so please add your subject matter expertise to this content by cloning the Github repository of this book and making a pull request with your changes.

We welcome all contributions, including but not limited to:

  • summarizing table packages
  • adding new example tables
  • clarifying requirements and analyses
  • improving R code

In case you are new to using git and GitHub but would like to make a contribution then please write a GitHub issue and we will reach out to you to add the content.

One convenient way to get started is to:

1.3 Data Used For Examples

We use synthetic data for the examples in this book. The data is available from the R package which contains a number of datasets that follow the CDISC ADaM specifications.


The data in is completely synthetic, meaning no patient data has been used to create it. The data is also fairly basic, meaning real study data often has more signal and patterns.

data(package="")$results[, "Item"]
 [1] "cadab"    "cadae"    "cadaette" "cadcm"    "caddv"    "cadeg"   
 [7] "cadex"    "cadhy"    "cadlb"    "cadmh"    "cadpc"    "cadpp"   
[13] "cadqlqc"  "cadqs"    "cadrs"    "cadsl"    "cadsub"   "cadtr"   
[19] "cadtte"   "cadvs"   

In this document, the prepending c stands for caches. So, for example the cached synthetic subject level dataset ADSL:

data("cadsl", package = "")
# A tibble: 6 × 55
  <chr>   <chr>       <chr>  <chr>  <int> <fct> <fct> <fct> <fct>  <fct>   <fct>
1 AB12345 AB12345-CH… id-128 CHN-3     32 YEARS M     ASIAN HISPA… CHN     Y    
2 AB12345 AB12345-CH… id-262 CHN-15    35 YEARS M     BLAC… NOT H… CHN     N    
3 AB12345 AB12345-RU… id-378 RUS-3     30 YEARS F     ASIAN NOT H… RUS     N    
4 AB12345 AB12345-CH… id-220 CHN-11    26 YEARS F     ASIAN NOT H… CHN     N    
5 AB12345 AB12345-CH… id-267 CHN-7     40 YEARS M     ASIAN NOT H… CHN     N    
6 AB12345 AB12345-CH… id-201 CHN-15    49 YEARS M     ASIAN NOT H… CHN     Y    
# ℹ 44 more variables: INVID <chr>, INVNAM <chr>, ARM <fct>, ARMCD <fct>,
#   ACTARM <fct>, ACTARMCD <fct>, TRT01P <fct>, TRT01A <fct>, TRT02P <fct>,
#   TRT02A <fct>, REGION1 <fct>, STRATA1 <fct>, STRATA2 <fct>, BMRKR1 <dbl>,
#   BMRKR2 <fct>, ITTFL <fct>, SAFFL <fct>, BMEASIFL <fct>, BEP01FL <fct>,
#   AEWITHFL <fct>, RANDDT <date>, TRTSDTM <dttm>, TRTEDTM <dttm>,
#   TRT01SDTM <dttm>, TRT01EDTM <dttm>, TRT02SDTM <dttm>, TRT02EDTM <dttm>,
#   AP01SDTM <dttm>, AP01EDTM <dttm>, AP02SDTM <dttm>, AP02EDTM <dttm>, …
adsl <- cadsl

1.4 Installing the R packages

At some point we may switch to renv to install the R packages used for this book. For right now you can install the packages yourself with:

install.packages(c("rtables", "tern", "gt", "remotes", "tidyverse", "bookdown",
                   "tables", "formatters", "tidytlg", "flextable"))


In each of the sections below, we will reset R to close to the present state at the start of the section, so readers can execute the demonstration code more or less independently of the other sections. This is done using the functions defined below. In your own documents, you wouldn’t need these resets.


R Core Team. 2023. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing.