I'm trying to install a package through the R prompt by doing the following:
install.packages('RMySQL')
But the output is as follows:
--- Please select a CRAN mirror for use in this session ---
And nothing else! I can't find a solution to this very basic problem. What am I supposed to type in order to select a CRAN mirror?
EDIT:
OS: Mac-OS X 10.6.8 R Version: 2.15.0
I use the ~/.Rprofile solution suggested by Dirk, but I just wanted to point out that
seems to be the sensible thing to do instead of
, which may work, but which involves the magic number 81 (or maybe this is subtle way to promote tourism to 81 = UK (Bristol) :-) )
A drop down menu should pop up for you to select from (or you will get a bunch of numbers to choose from), whether you are using R in the terminal or an IDE such as RStudio. This is supported on Windows, Mac OS, and most Linux systems. However, it may require additional configuration or dependencies such as X-windows.
To enable X-windows when using remote access use the following
-XY
flags:There is often a default repo but this can be specified if you have any issue, such as running scripts or Rmarkdown/knitr. You can use the
repo
opset the mirror or repository for CRAN each time you install with:It is advisable to use the nearest mirror to your location for faster downloads. For example:
You can also set the
repos
option in your session so you only need to it once per interactive session (or script). You can check whetherrepos
is configured with:If you get
"Error in options(repos) : object 'repos' not found"
then you can set the repository option. For example:Then it should work to install packages like usual. For Example:
As mentioned by others, you can configure the repository in your
.Rprofile
file and have this work across all of your scripts. It's up to you whether your prefer these "global" options on your system or "local" options in your session or script. These "local" options take more time to use each session but have the benefit of making others able to use your scripts if they don't have your.Rprofile
.You could also disable all graphical menus by running this or placing it in your Rprofile
If you need to set the mirror in a non-interactive way (for example doing an rbundler install in a deploy script) you can do it in this way:
First manually run:
Pick the mirror number that is best for you and remember it. Then to automate the selection:
Where 87 is the number of the mirror you would like to use. This snippet also installs the rbundle for you. You can omit that if you like.
I'm a fan of:
Which will print the list of mirrors in the output (no worrying a popup window since you are running it from the terminal) and then you enter the number you want.
Repository selection screen cannot be shown on your system (OS X), since OS X no longer includes X11. R tries to show you the prompt through X11. Install X11 from http://xquartz.macosforge.org/landing/. Then run the install command. The repo selection prompt will be shown.