Skip to content

Commit

Permalink
Rebuild vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
andrie committed Mar 31, 2017
1 parent de9967c commit 83c416a
Show file tree
Hide file tree
Showing 6 changed files with 759 additions and 0 deletions.
62 changes: 62 additions & 0 deletions vignettes/checkpoint.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
## ---- eval=FALSE---------------------------------------------------------
# library(checkpoint)
# checkpoint("2015-04-26", checkpointLocation = tempdir())

## ---- eval=FALSE, warning=FALSE------------------------------------------
# library(checkpoint)
# checkpoint("2015-04-26", checkpointLocation = tempdir())
#
# library(MASS)
# hist(islands)
# truehist(islands)

## ----setup, include=FALSE------------------------------------------------

## Create temporary project and set working directory

example_project <- tempdir()

dir.create(example_project, recursive = TRUE, showWarnings = FALSE)
oldRepos <- getOption("repos")
oldLibPaths <- .libPaths()


## Write dummy code file to project

example_code <- '
library(checkpoint)
checkpoint("2015-04-26", checkpointLocation = tempdir())
library(MASS)
hist(islands)
truehist(islands)
'

cat(example_code, file = file.path(example_project, "checkpoint_example_code.R"))


## ----checkpoint, warning=FALSE-------------------------------------------
## Create a checkpoint by specifying a snapshot date

library(checkpoint)
dir.create(file.path(tempdir(), ".checkpoint"), recursive = TRUE)
checkpoint("2015-04-26", project = example_project, checkpointLocation = tempdir())

## ----inspect-1-----------------------------------------------------------
getOption("repos")

## ----inspect-2-----------------------------------------------------------
normalizePath(.libPaths(), winslash = "/")

## ----inspect-3-----------------------------------------------------------
installed.packages()[, "Package"]

## ----cleanup, include=FALSE----------------------------------------------
## cleanup

unlink(example_project, recursive = TRUE)
unlink(file.path(tempdir(), "checkpoint_example_code.R"))
unlink(file.path(tempdir(), ".checkpoint"), recursive = TRUE)
options(repos = oldRepos)
unCheckpoint(oldLibPaths)

207 changes: 207 additions & 0 deletions vignettes/checkpoint.html

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions vignettes/managing-checkpoint-archives.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
## ---- eval=FALSE---------------------------------------------------------
# library(MASS)
# hist(islands)
# truehist(islands)

## ----setup-1, include=FALSE----------------------------------------------
## Write dummy code file to project
example_code <- '
library(MASS)
library(chron)
'
dir.create(tempdir(), recursive = TRUE)
cat(example_code, file = file.path(tempdir(), "managing_checkpoint_example_code.R"))

## ----checkpoint, results="hide", message=FALSE, warning=FALSE------------
## Create a checkpoint by specifying a snapshot date
library(checkpoint)
dir.create(file.path(tempdir(), ".checkpoint"), recursive = TRUE, showWarnings = FALSE)
checkpoint("2015-04-26", project = tempdir(), checkpointLocation = tempdir())


## ----archives-1----------------------------------------------------------
# List checkpoint archives on disk.
checkpointArchives(tempdir())

## ----archives-2----------------------------------------------------------
checkpointArchives(tempdir(), full.names = TRUE)

## ----access--------------------------------------------------------------
# Returns the date the snapshot was last accessed.
getAccessDate(tempdir())


## ----remove-1, eval=FALSE------------------------------------------------
# # Remove singe checkpoint archive from disk.
# checkpointRemove("2015-04-26")

## ----remove-2, eval=FALSE------------------------------------------------
# # Remove range of checkpoint archives from disk.
# checkpointRemove("2015-04-26", allSinceSnapshot = TRUE)
# checkpointRemove("2015-04-26", allUntilSnapshot = = TRUE)
#

## ----remove-3, eval=FALSE------------------------------------------------
# # Remove snapshot archives that have not been used recently
# checkpointRemove("2015-04-26", notUsedSince = TRUE)
#

## ----logfile-1-----------------------------------------------------------
dir(file.path(tempdir(), ".checkpoint"))

## ----logfile-2-----------------------------------------------------------

log_file <- file.path(tempdir(), ".checkpoint", "checkpoint_log.csv")
log <- read.csv(log_file)
head(log)

## ----uncheckpoint-1------------------------------------------------------
.libPaths()

## ----uncheckpoint-2------------------------------------------------------
# Note this is still experimental
unCheckpoint()
.libPaths()

## ----cleanup, include=FALSE----------------------------------------------
## cleanup
unlink("manifest.R")
unlink(file.path(tempdir(), "managing_checkpoint_example_code.R"))
unlink(file.path(tempdir(), ".checkpoint"), recursive = TRUE)

Loading

0 comments on commit 83c416a

Please sign in to comment.