10
votes

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

3
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
What does .libPaths() return? How about installed.packages()["plyr",]? - Brian Diggs
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 mirrors/dotsrc.org/cran/src/contrib - Sisse Camilla Lundholm
.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
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

3 Answers

15
votes

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.

3
votes

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

2
votes

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.