10

I use R 2.13.1 and have unsuccessfully tried to load the package "plyr 1.6" in R. I have manually installed it into a directory "~/R/library". My code is:

.libPaths("~/R/library")
 library(plyr)

I get the message:

Error in library(plyr) : 'plyr' is not a valid installed package

It works fine with other packages ("chron", "zoo", "ismev", "Lmoments"), but not for the "plyr" package, and I have no idea what is goin on. I have tried installing and loading earlier versions of "plyr", but with the same result.

I appreciate any help a lot since I am stuck! Regards Sisse

Gavin Simpson
  • 170,508
  • 25
  • 396
  • 453
  • 2
    Well, what steps have you taken to 'manually install' the package? Either way: what is wrong with installing it from CRAN? I think that also ensures that the necessary packages that `plyr` depends on itself, are installed... – Nick Sabbe Aug 31 '11 at 14:54
  • What does `.libPaths()` return? How about `installed.packages()["plyr",]`? – Brian Diggs Aug 31 '11 at 15:10
  • I downloaded the .tar.gz file and unpacked it. When I use "install.packages("package")" I get the message: Warning: unable to access the index for repository http://mirrors/dotsrc.org/cran/src/contrib – Sisse Camilla Lundholm Aug 31 '11 at 15:23
  • .libPaths() returns:"/home/scl/R/library" "/usr/local/lib/R/site-library" "/usr/lib/R/site-library" "/usr/lib/R/library". "installed.packages()["plyr"] gives NA. So after all, I guess that it is not even installed. – Sisse Camilla Lundholm Aug 31 '11 at 15:37
  • The error message you gave for `install.packages("plyr")` indicates that you have the mirror site wrong. It should be `mirrors.dotsrc.org/cran`, not `mirrors/dotsrc.org/cran`. Easiest way to set the mirror is with `chooseCRANmirror()`. And you are right, `plyr` has not been installed yet, as the results of `installed.packages()["plyr",]` shows (you did include the comma inside the brackets, yes?) – Brian Diggs Aug 31 '11 at 16:02
  • Yes, that is of course a good point. I have now changed the wrong periods to slashes in the /etc/apt/sources.list file. Thanks so much for your help! After 10 hours of work, I will have to wait until tomorrow to see if it did the trick. – Sisse Camilla Lundholm Aug 31 '11 at 17:03

3 Answers3

15

This isn't an answer to manually installing plyr. This is more answer about why you have to manually install in the first place.

I suspect your CRAN mirror is improperly set. To check, type

options("repos")[[1]][1]

This should return something like:

> options("repos")[[1]][1]
                                    CRAN 
"http://streaming.stat.iastate.edu/CRAN" 
> 

try setting your repo to a different mirror like this:

options(repos="http://streaming.stat.iastate.edu/CRAN")

or use any other mirror of your choice.

Then try loading plyr:

install.packages("plyr")
library("plyr") 

and let us know what happens.

JD Long
  • 59,675
  • 58
  • 202
  • 294
3

Might want to have a look at ?install.packages. It makes it very straightforward to install packages from CRAN. As simple as install.packages(pkgs="plyr").

Nick Sabbe
  • 11,684
  • 1
  • 43
  • 57
  • This essentially the same advice that Hadley offered to the cross-posted question on the manipulatr list @googlegroups.com. – IRTFM Aug 31 '11 at 16:10
2

Unpacking the tar.gz file only works if the package contains only R code. plyr uses external code, which isn't compiled if you just extract the source to a library.

Use install.packages with repos = NULL to install from the source file.

install.packages("path/to/the/file/plyr_1.6.tar.gz", repos = NULL)

In the long term, the best solution is to fix your internet issues. If you're on a corporate network, speak to your network admin because they are likely blocking the traffic.

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
  • I has a similar issue with another R package. I had to add type="source" to make it work 'install.packages("D:/xyz.tar.gz", type="source",repos = NULL)' – user131476 Aug 08 '13 at 08:51