Skip to content

Instantly share code, notes, and snippets.

@yonicd
Last active February 23, 2018 13:57
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 yonicd/2af049efe7af2f6e599619a35b7d17fe to your computer and use it in GitHub Desktop.
Save yonicd/2af049efe7af2f6e599619a35b7d17fe to your computer and use it in GitHub Desktop.
install R packages from github and keep the source install file
remotes_patch <- function(destdir=getwd()){
#patch install_remote
install_remote_keep_source <- remotes:::install_remote
install_remote_body <- body(install_remote_keep_source)
install_remote_body[[6]] <- quote(on.exit({
l <- list(...)
devtools::build(source,path = eval(enquote(l$destdir)))
unlink(source, recursive = TRUE)
}, add = TRUE))
body(install_remote_keep_source) <- install_remote_body
#patch install_remotes
install_remotes_keep_source <- remotes:::install_remotes
install_remotes_body <- body(install_remotes_keep_source)
install_remotes_body[[2]] <- quote(invisible(vapply(remotes, install_remote_keep_source,
..., FUN.VALUE = logical(1))))
body(install_remotes_keep_source) <- install_remotes_body
#patch install_github
install_github_keep_source <- remotes::install_github
install_github_body <- body(install_github_keep_source)
install_github_body[[3]] <- quote(install_remotes_keep_source(remotes, ...))
body(install_github_keep_source) <- install_github_body
#assign back to .GlobalEnv
assign('install_remote_keep_source',value = install_remote_keep_source,envir = .GlobalEnv)
assign('install_remotes_keep_source',value = install_remotes_keep_source,envir = .GlobalEnv)
assign('install_github_keep_source',value = install_github_keep_source,envir = .GlobalEnv)
}
#example
#remotes_patch()
#install_github_keep_source('metrumresearchgroup/vcs',destdir='~/projects/test/new')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment