问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/33256504/could-not-find-function-year-after-installation-from-zip-file-r