使用不同版本R的Rstudio项目 [英] 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?
上下文:我正在通过将R-portable与我的代码和一些其他脚本捆绑在一起来构建基于R的应用程序,以使其全部正常工作.我想在RStudio中使用应用程序中的R的可移植版本在我的项目上进行工作,而不会为我正在处理的所有其他RStudio项目更改我的R版本.
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.
推荐答案
这不是完整的答案,但是如果您真的想提醒您在RStudio项目中具有匹配的R版本,则可以强制停止脚本,如果版本号不匹配:
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.
这将提醒您从RStudio的全局选项中更改R版本号.
That will remind you to change the R version number from RStudio's global options.
这篇关于使用不同版本R的Rstudio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!