我的机构不会在我正在运行R的计算机上为我提供互联网访问权限。因此,我必须在一台PC上下载包含所有依赖项的软件包,然后在我的工作PC上从源代码安装它们。
使用this solution下载具有依赖项的包正常工作 但是,安装它们(例如用于lavaan):
install.packages(pkgs = "lavaan_0.5-20.tar.gz", repos = NULL, type = "source")
产生了几个警告:
Warnung: ungültiges Paket 'lavaan_0.5-20.tar.gz'
Fehler: Fehler: keine Pakete angegeben
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.0/bin/x64/R" CMD INSTALL -l "C:\Users\HIP\Documents\R\win-library\3.3" "lavaan_0.5-20.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘lavaan_0.5-20.tar.gz’ had non-zero exit status
我也尝试了this solution并使用了
library(tools)
write_PACKAGES("C:/Users/HIP/Documents/R/R_packages")
然后删除了PACKAGES.gz(如评论中所示)并使用
install.packages(pkgs="lavaan", type="source",
contriburl="file:///C:/Users/HIP/Documents/R/R_packages")
它给了我以下警告:
Warning in install.packages :
InternetOpenUrl failed: 'Der Servername oder die Serveradresse konnte nicht verarbeitet werden.'
Warning in install.packages :
InternetOpenUrl failed: 'Der Servername oder die Serveradresse konnte nicht verarbeitet werden.'
Warning in install.packages :
unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
InternetOpenUrl failed: 'Der Servername oder die Serveradresse konnte nicht verarbeitet werden.'
Warning in install.packages :
InternetOpenUrl failed: 'Der Servername oder die Serveradresse konnte nicht verarbeitet werden.'
Warning in install.packages :
unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
Installing package into ‘C:/Users/HIP/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘lavaan’ is not available (for R version 3.3.0)
有人知道可能是什么问题吗?非常感谢您的帮助!
谢谢!
答案 0 :(得分:1)
在 linux mint 上,我通过将整个路径(以 /home/... 开头)写入 tar.gz 文件来解决该问题。如果工作目录是tar.gz文件所在的目录,可以通过
install.packages(pkgs= paste(getwd(),"/lavaan_0.5-20.tar.gz",sep=""), repos = NULL, type ="source")