[英]Remote install of multiple R packages (with, without depends) from Ubuntu CLI
I have to perform a remote R installation on an Ubuntu 16.10 system. 我必须在Ubuntu 16.10系统上执行远程R安装。 As part of this, I have to install specific packages on that host.
作为此过程的一部分,我必须在该主机上安装特定的软件包。 I want to install these packages
Rcmdr
, list
, ggplot2
, afex
, lsmeans
. 我想安装这些软件包
Rcmdr
, list
, ggplot2
, afex
, lsmeans
。 Since I am doing this remotely, I cannot use 由于我是远程执行此操作,因此无法使用
sudo -i R
to first enter the R CLI and then install with install.packages()
. 首先进入R CLI,然后使用
install.packages()
进行安装。 Instead I must somehow install the packages from the Ubuntu CLI. 相反,我必须以某种方式从Ubuntu CLI安装软件包。
I found these links: 我找到了这些链接:
However, some packages have dependencies: 但是,某些软件包具有依赖性:
list
package depends on utils
and sandwich
. list
包取决于utils
和sandwich
。 Rcmdr
package depends on grDevices
, utils
, splines
, RcmdrMisc
, car
. Rcmdr
软件包取决于grDevices
, utils
, splines
, RcmdrMisc
, car
。 ggplot2
package also has dependencies. ggplot2
软件包还具有依赖性。 I would like to install only the packages Rcmdr
, list
, ggplot2
with all their dependencies. 我只想安装软件包
Rcmdr
, list
, ggplot2
及其所有依赖项。 Normally, I would do it this way: 通常,我会这样做:
install.packages(c('Rcmdr','list','ggplot2'), dependencies=TRUE)
QUESTIONS 质询
How do I specify the dependencies option in R CMD
for one package only? 如何仅在
R CMD
为一个包指定依赖项选项? Is this the way to install them 这是安装它们的方法
R CMD INSTALL -l Rcmdr dependencies=TRUE, list dependencies=TRUE, \\ ggplot2 dependencies=TRUE, afex, lsmeans
or this incorrect? 还是这个不正确?
repos
parameter inside R CMD INSTALL -l
? R CMD INSTALL -l
指定repos
参数? EDIT 编辑
As per the first comment below, sudo
is not needed above.ie sudo -i R
can be replaced by R
. 按照下面的第一评论,
sudo
不需要above.ie sudo -i R
可以被替换为R
Regarding your questions: 关于您的问题:
This may not be the best approach. 这可能不是最佳方法。 Consider instead
Rscript -e 'install.packages(...)'
which is what R CMD INSTALL ...
calls anyway. 而是考虑
Rscript -e 'install.packages(...)'
,这是R CMD INSTALL ...
仍然要调用的内容。 You have better control over options here. 您可以在此处更好地控制选项。 And read on...
继续读...
On all Ubuntu machines at work and home I do this via /etc/R/Rprofile.site
via something like 在工作和家庭中的所有Ubuntu计算机上,我都通过
/etc/R/Rprofile.site
来执行此/etc/R/Rprofile.site
,例如
## Example of Rprofile.site
local({
r <- getOption("repos")
r["CRAN"] <- "https://cloud.r-project.org"
r["ghrr"] <- "https://ghrr.github.io/drat"
options(repos = r)
})
where we usually add a third and network-local repo. 我们通常在其中添加第三个和网络本地存储库。 You may just want CRAN here -- it uses the 'always-close to you' CDN administered by RStudio for the R Project and R Consortium.
您可能只想在这里使用CRAN-它使用RStudio为R Project和R Consortium管理的“总是与您接近”的CDN。 The ghrr drat is a helper repo I set up.
ghrr drat是我设置的辅助仓库。
sudo
is not needed per something I add to the official Debian/Ubuntu package for R -- but you need to be a member of the group that owns /usr/local/lib/R/site-library
. 我在R的官方Debian / Ubuntu软件包中添加的某些内容都不需要
sudo
,但是您需要成为拥有/usr/local/lib/R/site-library
的组的成员。
Now, if I may, two more suggestions: 现在,如果可以的话,还有两个建议:
The r
executable is available to you via sudo apt-get install r-cran-littler
. 您可以通过
sudo apt-get install r-cran-littler
r
可执行文件。 I use it on the command-line; 我在命令行上使用它; and you probably want to look into the basic
install.r
script and the extended install2.r
. 并且您可能想要研究基本的
install.r
脚本和扩展的install2.r
。 I tend to create a softlink from /usr/local/bin
to the package directory for these and other (such as update.r
). 我倾向于创建从
/usr/local/bin
到这些目录和其他目录(例如update.r
)的软件包目录的软链接。 I have been running many (Ubuntu and Debian) machines like that for many years. 多年来,我一直在运行许多(Ubuntu和Debian)机器。
We actually have about 3000 CRAN packages as binaries for Ubuntu so you could just do sudo apt-get install ...
and all dependendies would get resolved. 实际上,我们有大约3000个CRAN软件包作为Ubuntu的二进制文件 ,因此您只需执行
sudo apt-get install ...
就可以解决所有依赖项。 Look eg in this script of mine (which uses them on Travis) or some of the Docker files I maintain such as this one . 看一下我的这个脚本 (在Travis上使用它们)或我维护的某些Docker文件(例如this) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.