禁用/抑制 R 中 CRAN 镜像选择的 tcltk 弹出窗口

发布于 2024-12-04 17:44:08 字数 420 浏览 0 评论 0原文

我的问题类似于之前发布的问题,但从未真正在这里得到解答:

禁用 GUI、图形设备在 R 中,

我不喜欢用于 CRAN 镜像选择的 R tcltk 弹出窗口。当在两个包中搜索某个函数的帮助时,它们也会弹出来选择一个包。

有没有办法在不完全禁用 X11 的情况下禁用这些窗口?我仍然希望plot()命令正常工作,但禁用那些需要永远通过远程连接加载的小选择菜单。

例如,如果您使用 ssh,但不使用 -X,则镜像选择只是 R 中的文本,您键入一个数字。速度很快。这就是我想要的,但是为图 b 保留 X11。

有人知道如何维护图形窗口但禁用“选择”tcltk 窗口吗?

My question is similar to a question previously posted but never really answered here:

Disable GUI, graphics devices in R

I do not like the R tcltk popups for CRAN mirror selection. They also pop up to choose a package when searching for help on a function in two packages.

Is there any way to disable these windows without disabling X11 completely? I still want plot() commands to work as normal, but disable the little select menus that take forever to load over a remote connection.

For example, if you use ssh, but don't use -X, then the mirror select is just text within R, you type a number. It's fast. This is what I want, but maintaining X11 for plots b.

Anyone know how to maintain graphics windows but disable the "choice" tcltk windows?

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

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

发布评论

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

评论(5

嘿哥们儿 2024-12-11 17:44:08

Dirk 提供了完全避免菜单的方法,但为了回答您提出的问题,我想您希望

options(menu.graphics=FALSE)

我通过查找从 help 返回的对象类来跟踪此选项(它是 help_files_with_topic code>),扫描 utils:::print.help_files_with_topic 并找到该行

menu(txt, title = gettext("Choose one"), graphics = getOption("menu.graphics"))

Dirk provides ways to avoid the menus altogether, but to answer your question as posed, I think you want

options(menu.graphics=FALSE)

I tracked this option down by finding the class of objects returned from help (it's help_files_with_topic), scanning utils:::print.help_files_with_topic and finding the line

menu(txt, title = gettext("Choose one"), graphics = getOption("menu.graphics"))
很酷不放纵 2024-12-11 17:44:08

只需在启动文件中设置镜像即可。我的 ~/.Rprofile 中有这个,但我从未看到该提示:

## Default repo
local({r <- getOption("repos");
       r["CRAN"] <- "http://cran.us.r-project.org"; 
       options(repos=r)})

请参阅 help(Startup) 了解更多可以在此处自定义的内容,还可以参阅 这个关于自定义 ~/.Rprofile 的优秀 SO 问题

编辑:至于您刚刚在评论中添加的附加问题,那是不同的。在这种情况下,您可以使用命名空间和 :: 运算符显式指定 mapply。例如,base::mapply(foo, bar) 会明确地从标准库中选择一个,同样 help(mapply, package="base") 会要求提供给定包中给定函数的帮助。

Just set a mirror in the startup files. I have this in my ~/.Rprofile and I never see that prompt:

## Default repo
local({r <- getOption("repos");
       r["CRAN"] <- "http://cran.us.r-project.org"; 
       options(repos=r)})

See help(Startup) for more things you can customize here, and also see this excellent SO question on customizing ~/.Rprofile.

Edit: As for your additional question just added in the comments, that is different. In this case you could specify the mapply explicitly by using the namespace and :: operator. For example, base::mapply(foo, bar) would unambiguously pick one from the standard library, and similarly help(mapply, package="base") asks for the help for a given function from a given package.

柒七 2024-12-11 17:44:08

如果您愿意,还可以查看 CRAN 中的 interactivity 包完全禁用交互式时髦的东西。

Also have a look at the interactivity package in CRAN if you wish to completley disable interactive funky stuff.

逆夏时光 2024-12-11 17:44:08

您还可以在 install.packages() 调用中指定存储库。这是在 R/4.3.0 上测试的,例如

install.packages("withr", repos = "http://cran.us.r-project.org")

You can also specify the repo within the install.packages() call. This was tested on R/4.3.0, e.g.

install.packages("withr", repos = "http://cran.us.r-project.org")

帅冕 2024-12-11 17:44:08

将其放在 ~/.Rprofile 中的新行上:

options(repos=c(CRAN="https://cran.r-project.org"))

重新启动 R 会话,CRAN 镜像弹出窗口将不会再打扰您!

注意:如果 ~/.Rprofile 不存在,您可以简单地创建它。不要忘记 . (这使其成为隐藏文件)。

替代方法(macOS、Linux)

您可以在终端中运行一次(它将把上面提到的行附加到 ~/.Rprofile 文件的底部!(这样您就不必跟踪它并手动编辑它)。您的 R 会话,这样它就会生效,并且 CRAN 镜像弹出窗口不会再次出现。

echo 'options(repos=c(CRAN="https://cran.r-project.org"))' >> ~/.Rprofile

注意

您可以设置任何您想要的 CRAN 镜像,"https://cran.r-project.org" 是。上面使用它是因为它是一个常见的

。此有用信息来自此处

Place this on a new line in ~/.Rprofile:

options(repos=c(CRAN="https://cran.r-project.org"))

Restart your R session and the CRAN mirror popup again won't hassle you again!

NOTE: if ~/.Rprofile doesn't exist, you can simply create it. Don't forget the . (that makes it a hidden file).

Alternate approach (macOS, linux)

You can just run this once in your terminal (it will append the line mentioned above to the bottom of your ~/.Rprofile file! (saving you having to track it down and manually edit it). Restart your R session so it takes effect, and the CRAN mirror popup won't appear again.

echo 'options(repos=c(CRAN="https://cran.r-project.org"))' >> ~/.Rprofile

Note

You can set any CRAN mirror you want, "https://cran.r-project.org" is used above because it's a common one.

Source

This useful info comes from here.

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