英文:
How to have a project with `renv` use the user `.Rprofile` as well as the project `.Rprofile`?
问题
我在用户 .Rprofile 中有很多 tidyverse 推荐的设置,但我注意到在使用 renv 的项目中并未生效,因为 renv 会创建一个特定于项目的 .Rprofile。
有没有办法配置 renv 始终使用用户 .Rprofile(即源化它),而不仅仅是项目的 .Rprofile?我不太理解这个关于 renv 用户级配置 的页面。
我知道这样做可能会减少可重复性,但我在用户 .Rprofile 中没有放置任何可能影响可重复性的内容,除了像下面这样的内容:
Sys.setenv("R_CHECK_LENGTH_1_CONDITION_" = "true")
这是 Hadley 推荐的做法。
英文:
I have a lot of tidyverse-recommended settings in my user .Rprofile that I noticed are not being used inside projects with renv because renv creates a project-specific .Rprofile.
Is there a way to configure renv to always use the user .Rprofile (i.e. source it) in addition to the project .Rprofile? I don't understand this page on renv user-level configuration.
I know this is less reproducible but I'm not placing anything in my user .Rprofile that would go against reproducibility except for something like
Sys.setenv("_R_CHECK_LENGTH_1_CONDITION_" = "true")
as recommended by Hadley.
答案1
得分: 1
是的,就像您提供的页面所说,您需要将选项 renv.config.user.profile 设置为 TRUE。默认值为 FALSE。
有两种方法可以做到这一点。
-
在使用
renv之前,在 R 中运行options(renv.config.user.profile = TRUE)。将此行放入您的.Rprofile文件中应该可以实现这一点。 -
在 R 之外设置环境变量
RENV_CONFIG_USER_PROFILE=TRUE。如何设置取决于您的系统(Windows、Linux、MacOS 等)。
英文:
Yes, as the page you linked says, you need to set the option renv.config.user.profile to TRUE. It defaults to FALSE.
There are two ways to do that.
-
Run
options(renv.config.user.profile = TRUE)in R before doing anything inrenv. Putting that line in your.Rprofilefile should do this. -
Set the environment variable
RENV_CONFIG_USER_PROFILE=TRUEoutside of R. How you do that depends on your system (Windows, Linux, MacOS, etc.).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论