Disable/suppress tcltk popup for CRAN mirror selection in R
Asked Answered
C

5

29

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?

Carnegie answered 15/9, 2011 at 11:59 Comment(1)
A pet peeve of mine too! Rstudio plots graphics with X window but blocks the ugly Tcl/tk popup. Thanks for asking this question.Meniscus
K
35

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"))
Kooky answered 15/9, 2011 at 13:40 Comment(1)
Yes! That is what I was looking for. I had looked in that options menu...Not sure how I missed that.Carnegie
S
12

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.

Scutum answered 15/9, 2011 at 13:3 Comment(5)
Alright, this solves for the mirror, but what about the "Choose one" dialog that comes up when you type "?mapply" and have 2 packages with "mapply" functions (like IRanges and base)? Loading Tcl/Tk interface...Carnegie
Ah well, with such an endorsement I just had to nitpick again :)Scutum
Now see what your nitpicking has done - the answer disappeared ! ;-)Interbrain
-1 for not answering the original question. Adding a "have you tried this instead?" comment is fine, but suggested alternatives may not apply in the OP's context, let alone the context of each person who has the same question, possibly even years later. Therefore they don't constitute an answer to the specific question asked.Enmity
Years later, but just wanted to defend Dirk (not that he needs it...); for most people searching for this question, this is almost certainly an X-Y problem where Dirk's answer is going to answer their underlying question better than my accepted answer will.Kooky
B
2

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

Beneath answered 23/10, 2012 at 17:47 Comment(1)
interactivity package has been removed from CRAN and doesn't seem to be available anywhere. Has it been mothballed? Which package to use instead?Besought
F
0

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")

Fairweather answered 29/6, 2023 at 14:46 Comment(0)
S
0

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.

Sello answered 22/3 at 3:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.