checkpoint() function enables reproducible research by managing your R package versions. These packages are downloaded into a local
If you use
checkpoint() for many projects, these local packages can consume some storage space, so the package also exposes functions to manage your snapshots.
In this vignette:
Managing local archives:
checkpointArchives(): list checkpoint archives on disk.
checkpointRemove(): remove checkpoint archive from disk.
getAccessDate(): returns the date the snapshot was last accessed.
.libPathsto the user library to undo the effect of
For illustration, set up a script referencing a single package:
# Example from ?darts library(darts) x = c(12,16,19,3,17,1,25,19,17,50,18,1,3,17,2,2,13,18,16,2,25,5,5, 1,5,4,17,25,25,50,3,7,17,17,3,3,3,7,11,10,25,1,19,15,4,1,5,12,17,16, 50,20,20,20,25,50,2,17,3,20,20,20,5,1,18,15,2,3,25,12,9,3,3,19,16,20, 5,5,1,4,15,16,5,20,16,2,25,6,12,25,11,25,7,2,5,19,17,17,2,12) mod = simpleEM(x, niter=100) e = simpleExpScores(mod$s.final) oldpar <- par(mfrow=c(1, 2)) drawHeatmap(e) drawBoard(new=TRUE) drawAimSpot(e, cex = 5) par(oldpar)
Next, create the checkpoint:
dir.create(file.path(tempdir(), ".checkpoint"), recursive = TRUE, showWarnings = FALSE) options(install.packages.compile.from.source = "no") oldLibPaths <- .libPaths() ## Create a checkpoint by specifying a snapshot date library(checkpoint) checkpoint("2017-04-01", project = tempdir(), checkpointLocation = tempdir())
You can query the available snapshots on disk using the
checkpointArchives() function. This returns a vector of snapshot folders.
##  "2017-04-01"
You can get the full paths by including the argument
##  "C:/Users/hongo/AppData/Local/Temp/RtmpEPckx0/.checkpoint/2017-04-01"
Every time you use
checkpoint() the function places a small marker in the snapshot archive with the access date. In this way you can track when was the last time you actually used the snapshot archive.
## C:/Users/hongo/AppData/Local/Temp/RtmpEPckx0/.checkpoint/2017-04-01 ## "2020-01-13"
Since the date of last access is tracked, you can use this to manage your checkpoint archives.
checkpointRemove() will delete archives from disk. You can use this function in multiple ways. For example, specify a specific archive to remove:
You can also remove a range of snapshot archives older (or more recent) than a snapshot date
Finally, you can remove all snapshot archives that have not been accessed since a given date:
One of the side effects of
checkpoint() is to create a log file that contains information about packages that get downloaded, as well as the download size.
This file is stored in the checkpoint root folder, and is a csv file with column names, so you can read this with your favourite R function or other tools.
##  "2017-04-01" "R-3.6.1" "checkpoint_log.csv"
Inspect the log file:
## timestamp snapshotDate pkg bytes ## 1 2020-01-13 18:22:37 2017-04-01 darts 7011
Use the function
unCheckpoint() to reset your
.libPaths to the user folder.
##  "C:/Users/hongo/AppData/Local/Temp/RtmpEPckx0/.checkpoint/2017-04-01/lib/x86_64-w64-mingw32/3.6.1" ##  "C:/Users/hongo/AppData/Local/Temp/RtmpEPckx0/.checkpoint/R-3.6.1" ##  "C:/PROGRA~1/R/R-36~1.1/library"
unCheckpoint() to reset your library paths
##  "C:/Users/hongo/AppData/Local/Temp/RtmpaamF46/Rinsta6383cf163d9" ##  "C:/Users/hongo/AppData/Local/Temp/RtmpEhrViz/temp_libpath9fbc66654fd6" ##  "c:/Rlib" ##  "C:/Program Files/R/R-3.6.1/library"