|
| 1 | +## ---- eval=FALSE--------------------------------------------------------- |
| 2 | +# library(MASS) |
| 3 | +# hist(islands) |
| 4 | +# truehist(islands) |
| 5 | + |
| 6 | +## ----setup-1, include=FALSE---------------------------------------------- |
| 7 | +## Write dummy code file to project |
| 8 | +example_code <- ' |
| 9 | +library(MASS) |
| 10 | +library(chron) |
| 11 | +' |
| 12 | +dir.create(tempdir(), recursive = TRUE) |
| 13 | +cat(example_code, file = file.path(tempdir(), "managing_checkpoint_example_code.R")) |
| 14 | + |
| 15 | +## ----checkpoint, results="hide", message=FALSE, warning=FALSE------------ |
| 16 | +## Create a checkpoint by specifying a snapshot date |
| 17 | +library(checkpoint) |
| 18 | +dir.create(file.path(tempdir(), ".checkpoint"), recursive = TRUE, showWarnings = FALSE) |
| 19 | +checkpoint("2015-04-26", project = tempdir(), checkpointLocation = tempdir()) |
| 20 | + |
| 21 | + |
| 22 | +## ----archives-1---------------------------------------------------------- |
| 23 | +# List checkpoint archives on disk. |
| 24 | +checkpointArchives(tempdir()) |
| 25 | + |
| 26 | +## ----archives-2---------------------------------------------------------- |
| 27 | +checkpointArchives(tempdir(), full.names = TRUE) |
| 28 | + |
| 29 | +## ----access-------------------------------------------------------------- |
| 30 | +# Returns the date the snapshot was last accessed. |
| 31 | +getAccessDate(tempdir()) |
| 32 | + |
| 33 | + |
| 34 | +## ----remove-1, eval=FALSE------------------------------------------------ |
| 35 | +# # Remove singe checkpoint archive from disk. |
| 36 | +# checkpointRemove("2015-04-26") |
| 37 | + |
| 38 | +## ----remove-2, eval=FALSE------------------------------------------------ |
| 39 | +# # Remove range of checkpoint archives from disk. |
| 40 | +# checkpointRemove("2015-04-26", allSinceSnapshot = TRUE) |
| 41 | +# checkpointRemove("2015-04-26", allUntilSnapshot = = TRUE) |
| 42 | +# |
| 43 | + |
| 44 | +## ----remove-3, eval=FALSE------------------------------------------------ |
| 45 | +# # Remove snapshot archives that have not been used recently |
| 46 | +# checkpointRemove("2015-04-26", notUsedSince = TRUE) |
| 47 | +# |
| 48 | + |
| 49 | +## ----logfile-1----------------------------------------------------------- |
| 50 | +dir(file.path(tempdir(), ".checkpoint")) |
| 51 | + |
| 52 | +## ----logfile-2----------------------------------------------------------- |
| 53 | + |
| 54 | +log_file <- file.path(tempdir(), ".checkpoint", "checkpoint_log.csv") |
| 55 | +log <- read.csv(log_file) |
| 56 | +head(log) |
| 57 | + |
| 58 | +## ----uncheckpoint-1------------------------------------------------------ |
| 59 | +.libPaths() |
| 60 | + |
| 61 | +## ----uncheckpoint-2------------------------------------------------------ |
| 62 | +# Note this is still experimental |
| 63 | +unCheckpoint() |
| 64 | +.libPaths() |
| 65 | + |
| 66 | +## ----cleanup, include=FALSE---------------------------------------------- |
| 67 | +## cleanup |
| 68 | +unlink("manifest.R") |
| 69 | +unlink(file.path(tempdir(), "managing_checkpoint_example_code.R")) |
| 70 | +unlink(file.path(tempdir(), ".checkpoint"), recursive = TRUE) |
| 71 | + |
0 commit comments