C Appendix C: Saving Workspace

It is a good idea to save the R workspace so data and objects can be retrieved at later time. This is helpful for debugging. Given that for this example data are changing so often we might as well keep a snapshot of the data tied to each release. I may decide to stop saving these data. File name will change when I change the version number on git (e.g., v0.9). This code assumes you have a folder called data-archive to place these saved workspaces.

# version was defined at the beginning of the the
# index.Rmd file get current tag and use a filename
# prefix
currentversion <- system("git describe --tags", intern = T)
save.image(file = paste0("data-archive/", currentversion, 
  "-dataworkspace.RData"))
print(paste0("File name associated with this run is ", currentversion, 
  "-dataworkspace.RData"))
## [1] "File name associated with this run is v.95-123-g5a7aba6-dataworkspace.RData"