[英]How to update all the r packages in RStudio in Anaconda
I'm using RStudio in a renv environment in Anaconda. I want to update the r packages in renv all at once.我在Anaconda的renv环境下使用RStudio。我想一次性更新renv中的r包。 Merv's command in this post updates only one package at a time (in the following code it only updates the askpass package)
Merv 在这篇文章中的命令一次只更新一个 package(在下面的代码中它只更新askpass包)
conda install -n renv -c conda-forge r-askpass
However, since I have a long list of r packages to be updated, I wonder if there is any command that would update all r packages at once.但是,由于我有一长串要更新的 r 包,我想知道是否有任何命令可以一次更新所有 r 包。 Thank you.
谢谢你。
The CLI only offers two options: CLI 仅提供两个选项:
conda update pkg1 pkg2...
conda update --all
So, not anything where you can specify all R packages.因此,您不能在任何地方指定所有 R 包。
One trick to get something in between would be to use the regex capability of conda list
to obtain a list of matching packages, then use some UNIX commands to send these as arguments to the conda update
command.获得介于两者之间的一个技巧是使用
conda list
的正则表达式功能来获取匹配包的列表,然后使用一些 UNIX 命令将它们作为 arguments 发送到 conda conda update
命令。
Here's what doing that for all packages that start with either r-
or bioconductor-
(the two most common prefixes for R packages) would look like:以下是对所有以
r-
或bioconductor-
开头的包(R 包的两个最常见的前缀)所做的操作,如下所示:
# environment you wish to update
ENV_NAME=renv
# update all `r-` and `bioconductor-` packages
conda list -n ${ENV_NAME} '^(r|bioconductor)-' | \
grep -vE '^#' | cut -f1 -d' ' | \
xargs conda update -n ${ENV_NAME} -d
Important Note : I include the -d
(dry run) flag in conda update
to prevent automatic acceptance of proposed changes, which seems to be triggered by the use of xargs
here.重要说明:我在
conda update
中包含-d
(试运行)标志以防止自动接受提议的更改,这似乎是由此处使用xargs
触发的。 I strongly recommend using this as is first (always review the changes,), and then after reviewing, execute again without the -d
.我强烈建议首先按原样使用它(始终检查更改,),然后在检查后再次执行而不使用
-d
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.