Configures R session to use packages as they existed on CRAN at time of snapshot.

Together, the checkpoint package and the checkpoint server act as a CRAN time machine. The checkpoint() function installs the packages referenced in the specified project to a local library exactly as they existed at the specified point in time. Only those packages are available to your session, thereby avoiding any package updates that came later and may have altered your results. In this way, anyone using the checkpoint checkpoint() function can ensure the reproducibility of your scripts or projects at any time.

checkpoint(snapshotDate, project = getwd(), R.version, scanForPackages = TRUE, checkpointLocation = "~/", verbose = TRUE, use.knitr = system.file(package = "knitr") != "", auto.install.knitr = TRUE, scan.rnw.with.knitr = FALSE)
Date of snapshot to use in YYYY-MM-DD format,e.g. "2014-09-17". Specify a date on or after "2014-09-17". MRAN takes one snapshot per day.
A project path. This is the path to the root of the project that references the packages to be installed from the MRAN snapshot for the date specified for snapshotDate. Defaults to current working directory using getwd().
Optional character string, e.g. "3.1.2". If specified, compares the current R.version to the specified R.version. If these differ, stops processing with an error, making no changes to the system. Specifically, if the check fails, the library path is NOT modified. This argument allows the original script author to specify a specific version of R to obtain the desired results.
If TRUE, scans for packages in project folder (see details). If FALSE, skips the scanning process. A use case for scanForPackages = FALSE is to skip the scanning and installation process, e.g. in production environments with a large number of R scripts in the project. Only set scanForPackages = FALSE if you are certain that all package dependencies are already in the checkpoint folder.
File path where the checkpoint library is stored. Default is "~/", i.e. the user's home directory. A use case for changing this is to create a checkpoint library on a portable drive (e.g. USB drive).
If TRUE, displays progress messages.
If TRUE, parses all Rmarkdown files using the knitr package.
If TRUE and the project contains rmarkdown files, then automatically included the packages knitr and rmarkdown in packages to install.
If TRUE, uses knit to parse .Rnw files, otherwise use Sweave

Checkpoint is called for its side-effects (see the details section), but invisibly returns a list with elements:
  • files_not_scanned
  • pkgs_found
  • pkgs_not_on_mran
  • pkgs_installed


checkpoint() creates a local library into which it installs a copy of the packages required by your project as they existed on CRAN on the specified snapshot date. Your R session is updated to use only these packages. To automatically determine all packages used in your project, the function scans all R code (.R, .Rmd, and .Rpres files) for library() and require() statements. In addition, scans for occurrences of code that accesses functions in namespaces using package::foo() and package:::foo(). Finally, any occurrences of the functions setClass, setRefClass, setMethod or setGeneric will also identify the methods package as a dependency. Specifically, the function will:

  • Create a new local snapshot library to install packages. By default this library folder is at ~/.checkpoint but you can modify the path using the checkpointLocation argument.
  • Update the options for your CRAN mirror and point to an MRAN snapshot using options(repos)
  • Scan your project folder for all required packages and install them from the snapshot using install.packages()

Resetting the checkpoint

To reset the checkpoint, simply restart your R session.

Changing the default MRAN url

checkpoint uses https by default to download packages (see checkpoint Defaults to by default in R versions 3.2.0 and later, if https support is enabled. You can modify the default URL. To change the URL, use options(checkpoint.mranUrl = ...)

  • checkpoint
## Not run: 
# # Create temporary project and set working directory
# example_project <- paste0("~/checkpoint_example_project_", Sys.Date())
# dir.create(example_project, recursive = TRUE)
# oldwd <- setwd(example_project)
# # Write dummy code file to project
# cat("library(MASS)", "library(foreach)",
#     sep="\n",
#     file="checkpoint_example_code.R")
# # Create a checkpoint by specifying a snapshot date
# library(checkpoint)
# checkpoint("2014-09-17")
# # Check that CRAN mirror is set to MRAN snapshot
# getOption("repos")
# # Check that library path is set to ~/.checkpoint
# .libPaths()
# # Check which packages are installed in checkpoint library
# installed.packages()
# # cleanup
# unlink(example_project, recursive = TRUE)
# setwd(oldwd)
# ## End(Not run)

Documentation reproduced from package checkpoint, version 0.3.16, License: GPL-2

Community examples

Looks like there are no examples yet.