1

I'm using R and working on a server without internet connection. So I had to search how to install packages from a zip file. I wanted to use the lubridate package.

install.packages("V:/R/lubridate_1.3.3.zip", repos=NULL)

Then I tried to use

library(lubridate) 
year(data$date)

but I received an error that package or namespace load failed for "lubridate". And the function year could not be found.

Did I forgot any step?

David Arenburg
  • 91,361
  • 17
  • 137
  • 196
psoares
  • 4,733
  • 7
  • 41
  • 55
  • 1
    Have you installed lubridate's imports (and their dependency trees)? – Roland Oct 21 '15 at 10:57
  • I just installed the zip file named lubridate_1.3.3.zip. I didn't do anything else. I tried again and it actually says `there is no package called plyr`. Could it be because of that? – psoares Oct 21 '15 at 11:04
  • 1
    That is likely the problem. As @Roland points out, you need to install `lubridate` and all of its dependencies and all of the dependencies' dependencies. This is something `install.packages` does for you. Can you copy files from your local machine to the server? It might be easier to install `lubridate` on your local machine, run `update.packages`, and then copy your library from your local machine to your server. – Benjamin Oct 21 '15 at 11:59
  • Thank you for your help! No, I can't but I already asked them to copy the zip file for plyr inside the server. Hopefully that may be enough for `lubridate` to work. Once it's installed I will let you know! – psoares Oct 21 '15 at 12:06
  • You need plyr, stringr, memoise, Rcpp, stringi, magrittr, and digest. – Roland Oct 21 '15 at 13:42
  • @Roland if you want to write a response with everything you told me so far I would glady accept it. In case someone has the same problem in the future. – psoares Oct 21 '15 at 14:10

1 Answers1

3

If you install a package with install.packages from a CRAN mirror, the imports and dependency tree is installed automatically. If you download the zip and do an offline installation that's obviously not possible. Thus, you have to download and install all these packages, too.

You can find the primary dependencies and imports from lubridate's CRAN page and then follow the links to get the whole trees. Or you can get it even more easily from MRAN.

If I didn't miss anything, you need plyr, stringr, memoise, Rcpp, stringi, magrittr, and digest.

This method is also probably not really feasible for packages with big dependency trees. You could use the function from this SO answer in such a case.

Community
  • 1
  • 1
Roland
  • 127,288
  • 10
  • 191
  • 288