5

I'm having a particularly hard time trying to get the 'fpc' package in R to install on Ubuntu 13.04.

The code I've written contains a line like:

install.packages('fpc') ; library(fpc)

which gives the output:

Error in contrib.url(repos, type) : 
 trying to use CRAN without setting a mirror
Calls: install.packages -> grep -> contrib.url
Execution halted

I haven't messed around with the .Rprofile file yet, and googling the issue reveals that this may be the cause (https://stat.ethz.ch/pipermail/r-devel/2009-October/055136.html) - the response here is pretty cryptic (and all I understand from this link is that I may not be setting a mirror).

Anyway, I've literally downloaded all packages from apt-get:

sudo apt-get install r-cran-*

and so far that hasn't fixed the issue. Any suggestions??

Thanks!

astromax
  • 6,001
  • 10
  • 36
  • 47

1 Answers1

3

If you do help(install.packages) you can see how to set a CRAN site in the call itself. But for what it is worth, I use this line in my ~/.Rprofile

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

which I have broken over two lines here for the formatting. Adjust as needed for a local mirror.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • Great! That seemed to do the trick. By the way, do you advise keeping my .Rprofile in my home directory? – astromax May 30 '13 at 15:42
  • The user's `.Rprofile` is in `$HOME`; I have also set this for multiple users in `$RHOME/etc/Rprofile.site`. Your call, it is nice to have options. – Dirk Eddelbuettel May 30 '13 at 15:45
  • I got the same error while I try to do sudo /usr/bin/R -e "devtools::install_github('rCharts','ramnathv')" on my linux server – BigDataScientist Feb 04 '14 at 21:06