您可以打印/回显来自 .Renviron 的消息吗?

发布于 2025-01-15 00:49:41 字数 304 浏览 2 评论 0原文

是否可以从 .Renviron 打印消息,以便在启动时在 RStudio 中显示它?

例如:

R_LIBS_USER="C:/Rlib/"
APIKEY="blabla"
echo Company envvar set

我不想使用 .Rprofile,因为它在项目中被覆盖。

编辑:

这是在 Windows 上本地安装的 R 上。我们以软件包的形式向某个 AD 组的所有成员推出 R/Rstudio/Rtools。正是在这个过程中我想做一些配置和信息。

It is possible to print messages from .Renviron so it is shown in RStudio at startup?

For example:

R_LIBS_USER="C:/Rlib/"
APIKEY="blabla"
echo Company envvar set

I don't want to use .Rprofile as that is overwriten in projects.

EDIT:

This is on locally installed R on windows. We roll out R/Rstudio/Rtools in a software package to all members of a certain AD group. It is in this process that I would like to do some configurations and information.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

子栖 2025-01-22 00:49:41

如上所述,您可以在 R/R-4.xx/etc/Renviron.site 中设置环境变量,以便为所有用户设置这些变量,即使涉及项目:

hello_message = "Hello! This has worked!"

然后设置 R/R -4.xx/etc/Rprofile.site 打印这些变量:

message(Sys.getenv("hello_message"))

然后启动一个新会话,在项目内部外部将设置所有变量并打印所有消息:

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

...

Hello! This has worked!
> 

As noted above you could set environment variables in R/R-4.x.x/etc/Renviron.site to set these for all users, even when projects are involved:

hello_message = "Hello! This has worked!"

Then set R/R-4.x.x/etc/Rprofile.site to print these variables:

message(Sys.getenv("hello_message"))

Then starting a new session, inside outside of a project will set all variables and print all messages:

R version 4.1.2 (2021-11-01) -- "Bird Hippie"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

...

Hello! This has worked!
> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文