Setting default url for R to look for packages in Mac OS X
Mac64 R> install.packages("quantmod")
Yields a discouraging message. Namely,
War开发者_StackOverflowning: unable to access index for repository http://www.ibiblio.org/pub/languages /R/CRAN/bin/macosx/leopard/contrib/2.12
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘quantmod’ is not available
No big deal, just pass in a different repo, like this:
Mac64 R> install.packages("quantmod", repo="http://R.research.att.com")
And all is well. But how do you set the default repo so you don't need to pass it in every time? In Ubuntu, there is a file that manages this but the documentation for Mac OS X is a bit sparse.
Can't tell if you are using the R64.app GUI but guessing that you may not be. You can set the default repository in the r/Preferences/ panels if you are using R64.app. Personally I use the repository at the same facility that hosts StatLib which shows up on some dialogs something like USA (PA 1) but on my Preferences pane is http://lib.stat.cmu.edu/R/CRAN . Here is a bit of ?options that may be of interest:
repos:
URLs of the repositories for use by update.packages. Defaults to
c(CRAN="@CRAN@"), a value that causes some utilities to prompt for
a CRAN mirror. To avoid this do set the CRAN mirror, by something
like local({r <- getOption("repos"); r["CRAN"] <- "http://my.local.cran";
options(repos=r)}).
Note that you can add more repositories (Bioconductor and Omegahat, notably)
using setRepositories().
At the moment my "other repository" setting in the the R64.app is http://www.stats.ox.ac.uk/pub/RWin/bin/macosx/leopard/contrib/2.12/ , because I was doing something to get a package that was only at Ripley's site but it is usually set to R--Forge: http://r-forge.r-project.org/
See the help for function setRepositories
; you can manage your list of repositories in a GUI or by editing the file R_HOME/etc/repositories
.
You can know what is your R_HOME
directly in R:
> R.home()
[1] "/usr/lib/R"
http://cran.r-project.org/doc/manuals/R-admin.html#Managing-libraries
Try creating the folders and files as suggested for UNIX-like systems; chances are that R will check for them on OS X as well when looking for repo settings.
精彩评论