我在 Ubuntu 机器上安装 R 版本 3.0.2 (2013-09-25) 时遇到这个问题:
install.packages("randomForest")
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages :
'lib = "/usr/local/lib/R/site-library"' is not writable
如何解决?
最佳答案
对于 R 版本 3.2.2 (2015-08-14),应该解决这个问题,因为 R 在安装过程中建议使用不同的路径来存储 R 库。安装看起来像这样: (这里以'random'作为示例包)
install.packages('random')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages("random") :
'lib = "/usr/local/lib/R/site-library"' is not writable
Would you like to use a personal library instead? (y/n) y
Would you like to create a personal library
~/R/pc-linux-gnu-library/3.2
to install packages into? (y/n) y
因此在安装过程中用“y”回答这两个问题应该会正确安装包。
19 年 1 月 18 日更新
如果您不想将 R 包存储在其他文件中:
作为Antoine-Sac和 Robert TheSim指出您可以将自己添加到员工组,以便能够写入“站点库”。 (点击名字可以看到他们的重要补充)
在此更新之前,我在此评论中提到了使用“chmod o+w”更改文件夹“site-library”的权限的选项,以便能够对其进行写入。假设存在安全问题但在我警告过它时无法确定,但主要是在等待有人解决这个问题。 Antoine-Sac 和 Robert TheSim have done so同时。谢谢!
关于r - 库不可写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32540919/