Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zkamvar/259122819cb955fd714b to your computer and use it in GitHub Desktop.
Save zkamvar/259122819cb955fd714b to your computer and use it in GitHub Desktop.
library("devtools") # with_lib(), install_github()
tmp_lib <- file.path(tempdir(), ".lib")
dir.create(tmp_lib)
cran_pkg <- function(pkg, tmp_lib = tmp_lib){
## upgrade or downgrade a package here
## following example is upgrading to bleeding edge devel version
with_lib(tmp_lib, install.packages(pkg, repos = "http://cran.rstudio.com"))
## but this could also be a downgrade to the CRAN/released version!
}
dev_pkg <- function(pkg, tmp_lib = tmp_lib){
## upgrade or downgrade a package here
## following example is upgrading to bleeding edge devel version
with_lib(tmp_lib, install_github(pkg))
## but this could also be a downgrade to the CRAN/released version!
}
load_tmp <- function(pkg, tmp_lib = tmp_lib){
## explicitly load the affected packages from the temporary library
library(pkg, lib.loc = tmp_lib, character.only = TRUE)
}
## By using tmpdir, the library will be clobbered automatically when you leave R.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment