Created
November 18, 2014 08:56
-
-
Save andrie/17b7b8f31f461a1fdcb6 to your computer and use it in GitHub Desktop.
Easily set a snapshot date on MRAN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setSnapshot <- function(date){ | |
if(missing(date)) return(getOption("repos")) | |
repoDate <- paste0("http://mran.revolutionanalytics.com/snapshot/", date) | |
response <- tryCatch( | |
suppressWarnings(readLines(repoDate)), | |
error = function(e)e | |
) | |
if(inherits(response, "error")) stop(paste0("Invalid snapshot date.")) | |
options(repos = c(CRAN = repoDate)) | |
} | |
# Empty date field returns current repo | |
setSnapshot() | |
# Valid snapshot date | |
setSnapshot("2014-11-16") | |
# Invalid snapshot date (in future), returns error | |
setSnapshot("2024-11-16") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment