简体   繁体   中英

Rstudio project using different version of R

Rstudio can change the version of R it uses ( https://support.rstudio.com/hc/en-us/articles/200486138-Using-Different-Versions-of-R ). Is there a way to do this for a specific project?

Context : I'm building an R-based application by bundling R-portable with my code and some other scripts to make it all work. I'd like to work on my project from within RStudio, using the portable version of R within the app, without changing my R version for every other RStudio project I work on.

This is not a full answer, but if you really want to remind you that you have matching R version in a RStudio project, you could force the stop of the script if the version number does not match:

if (!(version$major == "3") | !(version$minor == "4.3")) { 
  stop(paste0("Version ",version$major,".",version$minor," is in use. R version 3.4.3 is required. Exiting.")) 
}

Error: Version 3.4.2 is in use. R version 3.4.3 is required. Exiting.

That will remind you to change the R version number from RStudio's global options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM