问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/46771608/rstudio-project-using-different-version-of-r