Skip to content

Commit c9b9e99

Browse files
committed
static 2nd vignette
1 parent 20df1c2 commit c9b9e99

File tree

2 files changed

+49
-48
lines changed

2 files changed

+49
-48
lines changed

vignettes/checkpoint.Rmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: "Using checkpoint for reproducible research"
33
author: "Andrie de Vries"
4-
date: "`r Sys.Date()`"
54
output:
65
rmarkdown::html_vignette:
76
toc: true
@@ -83,7 +82,7 @@ To create a checkpoint project, you do:
8382

8483
```r
8584
library(checkpoint)
86-
checkpoint("<checkpoint date>", checkpointLocation = tempdir())
85+
checkpoint("<checkpoint date>")
8786
```
8887

8988
4. Run the script.

vignettes/managing-checkpoint-archives.Rmd

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: "Managing checkpoint snapshot archives"
33
author: "Andrie de Vries"
4-
date: "`r Sys.Date()`"
54
output:
65
rmarkdown::html_vignette:
76
toc: true
@@ -53,54 +52,52 @@ par(oldpar)
5352
Next, create the checkpoint:
5453

5554

56-
```{r setup-1, include=FALSE}
57-
58-
## Write dummy code file to project
59-
example_code <- '
60-
library(darts)
61-
'
62-
dir.create(tempdir(), recursive = TRUE)
63-
cat(example_code, file = file.path(tempdir(), "managing_checkpoint_example_code.R"))
64-
```
65-
66-
```{r checkpoint, results="hide", message=FALSE, warning=FALSE}
55+
```r
6756
dir.create(file.path(tempdir(), ".checkpoint"), recursive = TRUE, showWarnings = FALSE)
6857
options(install.packages.compile.from.source = "no")
6958
oldLibPaths <- .libPaths()
7059

7160
## Create a checkpoint by specifying a snapshot date
7261
library(checkpoint)
73-
checkpoint("2015-04-26", project = tempdir(), checkpointLocation = tempdir())
74-
62+
checkpoint("2017-04-01", project = tempdir(), checkpointLocation = tempdir())
7563
```
7664

7765

7866

67+
7968
# Working with checkpoint archive snapshots
8069

8170
You can query the available snapshots on disk using the `checkpointArchives()` function. This returns a vector of snapshot folders.
8271

8372

84-
```{r archives-1}
73+
```r
8574
# List checkpoint archives on disk.
8675
checkpointArchives(tempdir())
8776
```
77+
```
78+
## [1] "2017-04-01"
79+
```
8880

8981
You can get the full paths by including the argument `full.names=TRUE`:
9082

91-
```{r archives-2}
83+
```r
9284
checkpointArchives(tempdir(), full.names = TRUE)
9385
```
94-
86+
```
87+
## [1] "C:/Users/hongo/AppData/Local/Temp/RtmpEPckx0/.checkpoint/2017-04-01"
88+
```
9589

9690
## Working with access dates
9791

9892
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.
9993

100-
```{r access}
94+
```r
10195
# Returns the date the snapshot was last accessed.
10296
getAccessDate(tempdir())
103-
97+
```
98+
```
99+
## C:/Users/hongo/AppData/Local/Temp/RtmpEPckx0/.checkpoint/2017-04-01
100+
## "2020-01-13"
104101
```
105102

106103

@@ -110,27 +107,25 @@ Since the date of last access is tracked, you can use this to manage your checkp
110107

111108
The function `checkpointRemove()` will delete archives from disk. You can use this function in multiple ways. For example, specify a specific archive to remove:
112109

113-
```{r remove-1, eval=FALSE}
114-
# Remove singe checkpoint archive from disk.
115-
checkpointRemove("2015-04-26")
110+
```r
111+
# Remove single checkpoint archive from disk.
112+
checkpointRemove("2017-04-01")
116113
```
117114

118115
You can also remove a range of snapshot archives older (or more recent) than a snapshot date
119116

120117

121-
```{r remove-2, eval=FALSE}
118+
```r
122119
# Remove range of checkpoint archives from disk.
123-
checkpointRemove("2015-04-26", allSinceSnapshot = TRUE)
124-
checkpointRemove("2015-04-26", allUntilSnapshot = = TRUE)
125-
120+
checkpointRemove("2017-04-01", allSinceSnapshot = TRUE)
121+
checkpointRemove("2017-04-01", allUntilSnapshot = TRUE)
126122
```
127123

128124
Finally, you can remove all snapshot archives that have not been accessed since a given date:
129125

130-
```{r remove-3, eval=FALSE}
126+
```r
131127
# Remove snapshot archives that have not been used recently
132-
checkpointRemove("2015-04-26", notUsedSince = TRUE)
133-
128+
checkpointRemove("2017-04-01", notUsedSince = TRUE)
134129
```
135130

136131

@@ -140,42 +135,49 @@ One of the side effects of `checkpoint()` is to create a log file that contains
140135

141136
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.
142137

143-
```{r logfile-1}
138+
```r
144139
dir(file.path(tempdir(), ".checkpoint"))
145140
```
141+
```
142+
## [1] "2017-04-01" "R-3.6.1" "checkpoint_log.csv"
143+
```
146144

147-
Inspect the log file:
148145

149-
```{r logfile-2}
146+
Inspect the log file:
150147

148+
```r
151149
log_file <- file.path(tempdir(), ".checkpoint", "checkpoint_log.csv")
152150
log <- read.csv(log_file)
153151
head(log)
154152
```
153+
```
154+
## timestamp snapshotDate pkg bytes
155+
## 1 2020-01-13 18:22:37 2017-04-01 darts 7011
156+
```
155157

156158

157159
# Resetting the checkpoint
158160

159-
In older versions of `checkpoint()` the only way to reset the effect of `checkpoint()` was to restart your R session.
160-
161-
In v0.3.20 and above, you can use the function `unCheckpoint()`. This will reset you `.libPaths` to the user folder.
161+
Use the function `unCheckpoint()` to reset your `.libPaths` to the user folder.
162162

163-
```{r uncheckpoint-1}
163+
```r
164164
.libPaths()
165165
```
166+
```
167+
## [1] "C:/Users/hongo/AppData/Local/Temp/RtmpEPckx0/.checkpoint/2017-04-01/lib/x86_64-w64-mingw32/3.6.1"
168+
## [2] "C:/Users/hongo/AppData/Local/Temp/RtmpEPckx0/.checkpoint/R-3.6.1"
169+
## [3] "C:/PROGRA~1/R/R-36~1.1/library"
170+
```
166171

167172
Now use `unCheckpoint()` to reset your library paths
168173

169-
```{r uncheckpoint-2}
170-
# Note this is still experimental
171-
unCheckpoint(oldLibPaths)
174+
```r
175+
unCheckpoint()
172176
.libPaths()
173177
```
174-
175-
176-
```{r cleanup, include=TRUE}
177-
## cleanup
178-
unlink("manifest.R")
179-
unlink(file.path(tempdir(), "managing_checkpoint_example_code.R"))
180-
unlink(file.path(tempdir(), ".checkpoint"), recursive = TRUE)
178+
```
179+
## [1] "C:/Users/hongo/AppData/Local/Temp/RtmpaamF46/Rinsta6383cf163d9"
180+
## [2] "C:/Users/hongo/AppData/Local/Temp/RtmpEhrViz/temp_libpath9fbc66654fd6"
181+
## [3] "c:/Rlib"
182+
## [4] "C:/Program Files/R/R-3.6.1/library"
181183
```

0 commit comments

Comments
 (0)