Could not find function “year” after installation from zip file R

萝らか妹 提交于 2019-12-12 03:21:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!