Skip to content

Instantly share code, notes, and snippets.

@kylebaron
Created March 7, 2017 20:23
Show Gist options
  • Save kylebaron/dc02fcfcdf9acc5757c20f317357ad6f to your computer and use it in GitHub Desktop.
Save kylebaron/dc02fcfcdf9acc5757c20f317357ad6f to your computer and use it in GitHub Desktop.
A function to set path
set_my_path <- function() {
FLAG <- "RTOOLS_WAS_SET"
rtools <- 'C:\\RBuildTools\\3.3\\bin;C:\\RBuildTools\\3.3\\gcc-4.6.3\\bin;'
if(Sys.getenv(FLAG)=="") {
message("setting your path")
Sys.setenv(PATH=paste0(rtools,Sys.getenv("PATH")))
do.call(Sys.setenv,setNames(list("yes"),FLAG))
}
if(!grepl(rtools,Sys.getenv("PATH"),fixed=TRUE)) {
stop("Your path does not include Rtools")
}
}
set_my_path()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment