Rstudio project using different version of R

谁都会走 提交于 2019-12-11 14:07:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!