Other Useful Packages

This list covers the wider purpose R packages that we have found most useful and those that most commonly form dependencies to the pharma-specific packages.

Another useful reference is this document from the R Foundation titled Regulatory Compliance and Validation Issues - A Guidance Document for the Use of R in Regulated Clinical Trial Environments, which shows a list of base and recommended R packages.


Tables

There is a current industry working group ongoing effort around tables and the advantages of different packages here, which will result in a paper. In general, the problem is best divided into the following categories:

Table Creation

flextable

Creates tables for HTML, PDF, Microsoft Word and PowerPoint documents from R Markdown


gt

Easily generate information-rich, publication-quality tables from R


huxtable

An R package to create styled tables in multiple output formats, with a friendly, modern interface.


mmtable2

Create and combine tables with a ggplot2/patchwork syntax.


Formatting and Rendering

There are different solutions already available, but during R/Pharma there was an announcement of the RStudio package tgen to solve the rendering problems consistently.


Graphs

ggplot2

An implementation of the Grammar of Graphics in R, and the most popular plotting package for static plots in R.


viridisLite

Colorblind-Friendly Color Maps for R



Utilities

tidyverse

Set of packages with a common API for data manipulation and TLGs (includes dplyr, ggplot2, etc)


diffdf

The diffdf package is designed to enable detailed comparison of two data.frames.


lintr

Static code analysis for R that checks adherence to a given style, syntax errors and possible semantic issues


styler

Pretty-prints R code without changing the user's formatting intent


renv

Helps you create reproducible environments for your R projects



Statistical packages

It would be impossible to capture all the relevant statistical packages, as there are potentially thousands of potential methods that could be applied in a study. Below we include a handful that are likely to be used in the majority of trial reporting events, and refer to the Cran Task Views (CTVs) that attempt to maintain a landscape of available packages other several important domains.

stats - Base R package with a lot of functionality useful for design and analysis of clinical trials

survival - Core survival analysis routines

car - R companion to applied regression

emmeans - Estimated marginal means, aka least-squares means

mmrm - Mixed models for repeated measures (link)

lme4 - Fit linear and generalized linear mixed-effects models

lmerTest - Tests in linear mixed effects models

broom - takes the messy output of built-in functions in R and turns them into tidy tibbles

VGAM - Vector generalized linear and additive models

It is also worth attracting attention here to the wider CTVs across several pertinent topics, such as:

Clinical Trials, Survival, Bayes, Missing data, and PK.


As you can appreciate with R such an ever-evolving language we would never be able to include and maintain a complete list of all recommended packages here, but we hope that this page helps to introduce to some of the most common packages used both within and beyond pharma.