简体   繁体   English

从Github安装R软件包时遇到问题

[英]Having issues installing an R package from Github

Please be patient with me as I'm a total noob, but I'm really trying to learn. 由于我是个菜鸟,请耐心等待,但我确实在努力学习。

I'm trying to make a choropleth map for my country, and found an R package on Github that handles it excellently. 我正在尝试为我的国家制作一个choropleth地图,并在Github上找到了一个很好处理的R包。 However, I'm working on a university computer and I don't have write privileges on any drive but M://, so whenever the package tries to install on C:// it obviously throws an error. 但是,我正在大学计算机上工作,除了M://之外,我没有任何驱动器写权限,因此,只要程序包尝试在C://上安装,显然都会引发错误。 This hasn't been a problem since I can just specify a libpath as an argument on install.packages, but devtools::install_github does not seem to have such an argument. 这不是问题,因为我只能在安装包中指定一个libpath作为参数,但是devtools :: install_github似乎没有这样的参数。

I tried using 我尝试使用

with_libpaths(new = "M:\R\win-library\3.2", install_github('diegovalle/mxmaps'))

But I got an error message saying 但是我收到一条错误消息说

with_libpaths' is deprecated. with_libpaths'已弃用。 Use 'withr::with_libpaths' instead. 使用'withr :: with_libpaths'代替。

I take this to mean that I need to install the "withr" package in order to use that? 我的意思是我需要安装“ withr”软件包才能使用它? However, I keep getting errors when trying to install that package. 但是,在尝试安装该软件包时,我总是收到错误消息。 First, I got 首先,我得到了

Warning in install.packages : installation of package 'withr' had non-zero exit status install.packages中的警告:软件包“ withr”的安装退出状态为非零

because of the not having access to C:// issue. 由于无法访问C://问题。 I usually bypass this by installing directly from the binaries, but when I try that it tells me 我通常通过直接从二进制文件安装来绕过此操作,但是当我尝试它告诉我时

"Warning in install.packages : package 'withr' is not available (for R version 3.2.2)". “在install.packages中警告:软件包'withr'不可用(对于R版本3.2.2)”。

Other than updating my version of R (which will be a nighmare since I don't have installation privileges on this machine), how else can I either install withr or find another way to specify the directory to install the package from github? 除了更新我的R版本(由于我在这台机器上没有安装特权,这将是一件麻烦事)之外,我还能如何安装withr或找到另一种方法来指定从github安装软件包的目录?

我建议您使用3.4的最新版本。上述所有软件包均在最新版本下提供。

Two ways to set local library paths (at least on Linux running R 3.5.3): 设置本地库路径的两种方法(至少在运行R 3.5.3的Linux上):

(1) At the beginning of your script, set the the .libPaths option to your local library path, ie: .libPaths("M:\\R\\win-library\\3.2") (1)在脚本的开头,将.libPaths选项设置为本地库路径,即: .libPaths("M:\\R\\win-library\\3.2")

(2) Add to your .Renviron file a line that specifies your local library path: ie: R_LIBS="M:\\R\\win-library\\3.2" (2)在.Renviron文件中添加指定本地库路径的行:即: R_LIBS="M:\\R\\win-library\\3.2"

Note: For (1) You will need to manually run every time you start a new R session, whereas (2) will be set automatically when R starts. 注意:对于(1),您将需要在每次启动新的R会话时手动运行,而(2)将在R启动时自动设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM