Task view: Reproducible Research

Last updated on 2021-12-20 by John Blischak, Alison Hill

The goal of reproducible research is to tie specific instructions to data analysis and experimental data so that scholarship can be recreated, better understood and verified. Packages in R for this purpose can be split into groups for: literate programming, pipeline toolkits, package reproducibility, project workflows, code/data formatting tools, format convertors, and object caching.

The maintainers gratefully acknowledge Anna Krystalli, Max Kuhn, Will Landau, Ben Marwick, and Daniel Nüst for their useful feedback and contributions.

If you would like to recommend a package to be included in this task view, please open a GitHub Issue to discuss.

Literate Programming

The primary way that R facilitates reproducible research is using a document that is a combination of content and data analysis code. The Sweave function (in the base R utils package) and the knitr package can be used to blend the subject matter and R code so that a single document defines the content and the analysis. The brew and R.rsp packages contain alternative approaches to embedding R code into various markups.

The resources for literate programming are best organized by the document type/markup language:


Both Sweave and knitr can process LaTeX files. lazyWeave can create LaTeX documents from scratch.

The knitr and rmarkdown packages (along with pandoc) can be used to create slides using the LaTeX beamer class.

Object Conversion Functions:

Miscellaneous Tools

  • Hmisc contains a function to correctly escape special characters. Standardized exams can be created using the exams package.


The knitr package can process HTML files directly. Sweave can also work with HTML by way of the R2HTML package. lazyWeave can create HTML format documents from scratch.

For HTML slides, a combination of the knitr and rmarkdown packages (along with pandoc) can be used to create slides using ioslides, reveal.js, Slidy, or remark.js (from the xaringan package).

Object Conversion Functions:

Miscellaneous Tools: htmltools has various tools for working with HTML. tufterhandout can create Tufte-style handouts.


The knitr package can process markdown files without assistance. The packages markdown and rmarkdown have general tools for working with documents in this format. lazyWeave can create markdown format documents from scratch. Also, the ascii package can write R objects to the AsciiDoc format.

Object Conversion Functions:

Miscellaneous Tools: tufterhandout can create Tufte-style handouts. kfigr allows for figure indexing in markdown documents.

Microsoft/LibreOffice Formats

The officer (formerly ReporteRs and before that R2DOCX) package can create docx and pptx files. R2wd (windows only) can also create Word documents from scratch and R2PPT (also windows only) can create PowerPoint slides. The rtf package does the same for Rich Text Format documents. The openxlsx package creates xlsx files. The readODS package can read and write Open Document Spreadsheets.

Object Conversion Functions:

Pipeline Toolkits

Pipeline toolkits help maintain and verify reproducibility. They synchronize computational output with the underlying code and data, and they tell the user when everything is up to date. In other words, they provide concrete evidence that results are re-creatable from the starting materials, and the data analysis project does not need to rerun from scratch. The targets package is such a pipeline toolkit. It is similar to GNU Make, but it is R-focused.

  • drake: A general-purpose computational engine for data analysis, drake rebuilds intermediate data objects when their dependencies change, and it skips work when the results are already up to date.
  • flowr: This framework allows you to design and implement complex pipelines, and deploy them on your institution's computing cluster.
  • makepipe: A suite of tools for transforming an existing workflow into a self-documenting pipeline with very minimal upfront costs.
  • repo: A data manager meant to avoid manual storage/retrieval of data to/from the file system.
  • targets: As a pipeline toolkit for Statistics and data science in R, the 'targets' package brings together function-oriented programming and 'Make'-like declarative workflows.

Package Reproducibility

R has various tools for ensuring that specific packages versions can be required for analyses. As an example, the renv package installs packages in project-specific directory, records "snapshots" of the current package versions in a "lockfile", and restores the package setup on a different machine.

  • checkpoint: Allows you to install packages as they existed on CRAN on a specific snapshot date as if you had a CRAN time machine.
  • groundhog: Make R scripts that rely on packages reproducible, by ensuring that every time a given script is run, the same version of the used packages are loaded.
  • liftr: Persistent reproducible reporting by containerization of R Markdown documents.
  • miniCRAN: Makes it possible to create an internally consistent repository consisting of selected packages from CRAN-like repositories.
  • packrat: Manage the R packages your project depends on in an isolated, portable, and reproducible way.
  • rbundler: Manages a project-specific library for dependency package installation.
  • renv: Create and manage project-local R libraries, save the state of these libraries to a 'lockfile', and later restore your library as required.
  • Require: A single key function, 'Require' that wraps 'install.packages', 'remotes::install_github', 'versions::install.versions', and 'base::require' that allows for reproducible workflows.
  • switchr: Provides an abstraction for managing, installing, and switching between sets of installed R packages.

Project Workflows

Successfully completing a data analysis project often requires much more than statistics and visualizations. Efficiently managing the code, data, and results as the project matures helps reduce stress and errors. The following "workflow" packages assist the R programmer by managing project infrastructure and/or facilitating a reproducible workflow.

Workflow utility packages provide single-use functions to implement project infrastructure or solve a specific problem. As a typical example, usethis::use_git() initializes a Git repository, ignores common R files, and commits all project files.

  • cabinets: Creates project specific directory and file templates that are written to a .Rprofile file.
  • here: Constructs paths to your project's files.
  • prodigenr: Create a project directory structure, along with typical files for that project.
  • RepoGenerator: Generates a project and repo for easy initialization of a GitHub repo for R workshops.
  • rrtools (GitHub only): Instructions, templates, and functions for making a basic compendium suitable for doing reproducible research with R.
  • starters (GitHub only): Setting up R project directories for teaching, presenting, analysis, package development can be a pain. starters shortcuts this by creating folder structures and setting good defaults for you.
  • usethis: Automate package and project setup tasks that are otherwise performed manually.

Workflow framework packages provide an organized directory structure and helper functions to assist during the development of the project. As a typical example, ProjectTemplate::create.project() creates an organized setup with many subdirectories, and ProjectTemplate::run.project() executes each R script that is saved in the src/ subdirectory.

  • exreport: Analysis of experimental results and automatic report generation in both interactive HTML and LaTeX.
  • madrat: Provides a framework which should improve reproducibility and transparency in data processing. It provides functionality such as automatic meta data creation and management, rudimentary quality management, data caching, work-flow management and data aggregation.
  • makeProject: This package creates an empty framework of files and directories for the "Load, Clean, Func, Do" structure described by Josh Reich.
  • orderly: Order, create and store reports from R.
  • projects: Provides a project infrastructure with a focus on manuscript creation.
  • ProjectTemplate: Provides functions to automatically build a directory structure for a new R project. Using this structure, 'ProjectTemplate' automates data loading, preprocessing, library importing and unit testing.
  • reportfactory: Provides an infrastructure for handling multiple R Markdown reports, including automated curation and time-stamping of outputs, parameterisation and provision of helper functions to manage dependencies.
  • represtools: Reproducible research tools automates the creation of an analysis directory structure and work flow. There are R markdown skeletons which encapsulate typical analytic work flow steps. Functions will create appropriate modules which may pass data from one step to another.
  • tinyProject: Creates useful files and folders for data analysis projects and provides functions to manage data, scripts and output files.
  • worcs: Create reproducible and transparent research projects in 'R'. This package is based on the Workflow for Open Reproducible Code in Science (WORCS), a step-by-step procedure based on best practices for Open Science.
  • workflowr: Provides a workflow for your analysis projects by combining literate programming ('knitr' and 'rmarkdown') and version control ('Git', via 'git2r') to generate a website containing time-stamped, versioned, and documented results.
  • zoon: Reproducible and remixable species distribution modelling.

Formatting Tools

formatR and styler can be used to format R code.

highlight and highr can be used to color R code.

Packages humanFormat, lubridate, prettyunits, and rprintf have functions to better format data.

Format Convertors

pander can be used for rendering R objects into Pandoc's markdown. knitr has the function pandoc that can call an installed version of Pandoc to convert documents between formats such as Markdown, HTML, LaTeX, PDF and Word. tth facilitates TeX to HTML/MathML conversions.

Object Caching Packages

When using Sweave and knitr it can be advantageous to cache the results of time consuming code chunks if the document will be re-processed (i.e. during debugging). knitr facilitates object caching and the Bioconductor package weaver can be used with Sweave.

Non-literate programming packages to facilitating caching/archiving are archivist, R.cache, reproducible, storr, and trackr.


animation — 2.7

A Gallery of Animations in Statistics and Utilities to Create Animations

apsrtable — 0.8-8

apsrtable model-output formatter for social science

archivist — 2.3.6

Tools for Storing, Restoring and Searching for R Objects

ascii — 2.4

Export R Objects to Several Markup Languages

bibtex —

Bibtex Parser

brew — 1.0-6

Templating Framework for Report Generation

cabinets — 0.6.0

Project Specific Workspace Organization Templates

checkpoint — 1.0.1

Install Packages from Snapshots on the Checkpoint Server for Reproducibility

drake — 7.13.3

A Pipeline Toolkit for Reproducible Computation at Scale

DT — 0.20

A Wrapper of the JavaScript Library 'DataTables'

exams — 2.3-6

Automatic Generation of Exams in R

exreport — 0.4.1

Fast, Reliable and Elegant Reproducible Research

flextable — 0.6.10

Functions for Tabular Reporting

flowr — 0.9.11

Streamlining Design and Deployment of Complex Workflows

formatR — 1.11

Format R Code Automatically

formattable — 0.2.1

Create 'Formattable' Data Structures

groundhog — 1.5.0

The Simplest Solution to Version-Control for CRAN Packages

here — 1.0.1

A Simpler Way to Find Your Files

highlight — 0.5.0

Syntax Highlighter

highr — 0.9

Syntax Highlighting for R Source Code

gt — 0.3.1

Easily Create Presentation-Ready Display Tables

Hmisc — 4.6-0

Harrell Miscellaneous

htmlTable — 2.4.0

Advanced Tables for Markdown/HTML

htmltools — 0.5.2

Tools for HTML

HTMLUtils — 0.1.7

Facilitates Automated HTML Report Creation

humanFormat — 1.0

Human-friendly formatting functions

huxtable — 5.4.0

Easily Create and Style Tables for LaTeX, HTML and Other Formats

hwriter — 1.3.2

HTML Writer - Outputs R objects in HTML format

latex2exp — 0.9.0

Use LaTeX Expressions in Plots

lazyWeave — 3.0.2

LaTeX Wrappers for R Users

liftr — 0.9.2

Containerize R Markdown Documents for Continuous Reproducibility

lubridate — 1.8.0

Make Dealing with Dates a Little Easier

kfigr — 1.2.1

Integrated Code Chunk Anchoring and Referencing for R Markdown Documents

knitcitations — 1.0.12

Citations for 'Knitr' Markdown Files

knitLatex — 0.9.0

'Knitr' Helpers - Mostly Tables

knitr — 1.37

A General-Purpose Package for Dynamic Report Generation in R

madrat — 2.3.2

May All Data be Reproducible and Transparent (MADRaT) *

makepipe — 0.1.0

Pipeline Tools Inspired by 'GNU Make'

makeProject — 1.0

Creates an empty package framework for the LCFD format

markdown — 1.1

Render Markdown with the C Library 'Sundown'

memisc —

Management of Survey Data and Presentation of Analysis Results

miniCRAN — 0.2.14

Create a Mini Version of CRAN Containing Only Selected Packages

mschart — 0.3.1

Chart Generation for 'Microsoft Word' and 'Microsoft PowerPoint' Documents

NMOF — 2.5-0

Numerical Methods and Optimization in Finance

officer — 0.4.1

Manipulation of Microsoft Word and PowerPoint Documents

openxlsx — 4.2.5

Read, Write and Edit xlsx Files

orderly — 1.4.3

Lightweight Reproducible Reporting

packrat — 0.7.0

A Dependency Management System for Projects and their R Package Dependencies

pander — 0.6.4

An R 'Pandoc' Writer

papeR — 1.0-5

A Toolbox for Writing Pretty Papers and Reports

pharmaRTF — 0.1.4

Enhanced RTF Wrapper for Use with Existing Table Packages

prettyunits — 1.1.1

Pretty, Human Readable Formatting of Quantities

prodigenr — 0.6.1

Research Project Directory Generator

projects — 2.1.3

A Project Infrastructure for Researchers

ProjectTemplate — 0.10.2

Automates the Creation of New Statistical Analysis Projects

quantreg — 5.87

Quantile Regression

R.cache — 0.15.0

Fast and Light-Weight Caching (Memoization) of Objects and Results to Speed Up Computations

R.rsp — 0.44.0

Dynamic Generation of Scientific Reports

R2HTML — 2.3.2

HTML Exportation for R Objects

R2PPT — 2.1

Simple R Interface to Microsoft PowerPoint using rcom or RDCOMClient.

r2rtf — 0.3.2

Easily Create Production-Ready Rich Text Format (RTF) Table and Figure

R2wd — 1.5

Write MS-Word documents from R

rapport — 1.1

A Report Templating System

rbundler — 0.3.7

Rbundler manages an application's dependencies systematically and repeatedly.

readODS — 1.7.0

Read and Write ODS Files

RefManageR — 1.3.0

Straightforward 'BibTeX' and 'BibLaTeX' Bibliography Management

renv — 0.15.2

Project Environments

repo — 2.1.5

A Data-Centered Data Flow Manager

RepoGenerator — 0.0.1

Generates a Project and Repo for Easy Initialization of a Workshop

reportfactory — 0.4.0

Lightweight Infrastructure for Handling Multiple R Markdown Documents

reporttools — 1.1.3

Generate "LaTeX"" Tables of Descriptive Statistics

represtools — 0.1.3

Reproducible Research Tools

reproducible — 1.2.8

A Set of Tools that Enhance Reproducibility Beyond Package Management

Require — 0.0.13

Installing and Loading R Packages for Reproducible Workflows

rmarkdown — 2.11

Dynamic Documents for R

rms — 6.2-0

Regression Modeling Strategies

rprintf — 0.2.1

Adaptive Builder for Formatted Strings

rtf — 0.4-14.1

Rich Text Format (RTF) Output

sparktex — 0.1

Generate LaTeX sparklines in R

stargazer — 5.2.2

Well-Formatted Regression and Summary Statistics Tables

storr — 1.2.5

Simple Key Value Stores

styler — 1.6.2

Non-Invasive Pretty Printing of R Code

suRtex — 0.9

LaTeX descriptive statistic reporting for survey data

switchr — 0.14.3

Installing, Managing, and Switching Between Distinct Sets of Installed Packages

tables — 0.9.6

Formula-Driven Table Generation

targets — 0.10.0

Dynamic Function-Oriented 'Make'-Like Declarative Workflows

texreg — 1.37.5

Conversion of R Regression Output to LaTeX or HTML Tables

tikzDevice —

R Graphics Output in LaTeX Format

tinyProject — 0.6.1

A Lightweight Template for Data Analysis Projects

trackr — 0.10.7

Semantic Annotation and Discoverability System for R-Based Artifacts

tth — 4.12-0

TeX-to-HTML/MathML Translators TtH/TtM

tufterhandout — 1.2.1

Tufte-style html document format for rmarkdown

unrtf — 1.4.1

Extract Text from Rich Text Format (RTF) Documents

usethis — 2.1.5

Automate Package and Project Setup

worcs — 0.1.8

Workflow for Open Reproducible Code in Science

workflowr — 1.7.0

A Framework for Reproducible and Collaborative Data Science

xaringan — 0.22

Presentation Ninja

xtable — 1.8-4

Export Tables to LaTeX or HTML

zoon — 0.6.5

Reproducible, Accessible & Shareable Species Distribution Modelling

ztable — 0.2.3

Zebra-Striped Tables in LaTeX and HTML Formats

Task view list