安装所有尚未安装的 CRAN 软件包?
以下 R 命令将安装所有 CRAN 软件包:
availablePackages <- available.packages()[,1]
install.packages(availablePackages)
以下命令将列出所有已安装的软件包:
installedPackages <- .packages(all.available = TRUE)
我的问题是:如何指示 R 安装所有尚未安装的 CRAN 软件包?
The following R commands will install all CRAN packages:
availablePackages <- available.packages()[,1]
install.packages(availablePackages)
And the following command will list all installed packages:
installedPackages <- .packages(all.available = TRUE)
My question is: How do I instruct R to install all CRAN packages that are not already installed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
坦率地说,我认为这是一项艰苦的工作......它会持续几天,甚至几周(取决于资源),但这是代码(我只是喜欢做琐碎的事情):
我仍然不明白你为什么这样做,但是,嘿...有些事情就是不应该的...
最让我惊讶的是你已经回答了你自己的问题!你已经得到了你需要的东西,接下来就取决于你如何将它们组合在一起......
我们是否错过了重点?你还有别的想法吗?!?
Frankly, I think it's painstaking job... it would last for days, even weeks (depending on resources), but here's the code (I just enjoy doing trivial things):
I still don't get why you're doing this, but, hey... some things are just not meant to be....
What wonders me the most is the fact that you've already answered your own question! You got what you needed, and it's just up to you to put things together...
Are we missing the point? Did you have something else in mind?!?
1)你为什么要这么做?其中有超过 3500(截至 2012 年 2 月)?
2)您是否查看了 CRAN 任务视图 和 ctv 包允许您从给定任务安装包?
3)您的粗体问题是一个简单的索引查询,您可以手动执行(除此之外,还请参阅
help(sets)
)编辑:响应您的关注-up:
a) 如果软件包未通过 Linux 和 Windows 上的“R CMD 检查”,则不会将其上传到 CRAN。那么这项工作就完成了。
b) 正如你将看到的,让所有依赖都归于你自己也是一项工作。我们为 cran2deb 做了这个,它位于 http://debian.cran.r-project.org (它进行成熟的 Debian 软件包构建,而不仅仅是安装)。我们构建了 2150 个软件包中的大约 2050 个。有一些我们因为许可证而拒绝构建,有一些我们因为缺少标头或库而无法构建,还有一些我们无法构建,因为它们需要例如 BioConductor 包。
1) Why would you want to do that? There are over 3500 (as of Feb 2012) of them?
2) Did you look at CRAN Task Views and the ctv package that allows you to install packages from a given task?
3) You bold-face question is a simple indexing query you can do by hand (and besides that, also see
help(sets)
)Edit: in response to your follow-up:
a) If a package does not pass 'R CMD check' on Linux and Windows, it does not get uploaded to CRAN. So that job is done.
b) Getting all depends at your end is work too as you will see. We did it for cran2deb which is at http://debian.cran.r-project.org (which does full-blown Debian package building which is more than just installing). We get about 2050 out of 2150 packages built. There are a few we refuse to build because of license, a few we cannot because of missing headers or libs and a few we cannot build because they need e.g. BioConductor packages.
输入此命令,然后所有软件包将自动安装:
type this command and then all packages will be installed automatically:
如果您使用更好:
调用该函数并检查是否安装了所需的包:
Better if you use:
call the function and check if required package is installed:
我已经测试过这个并且它
有效
I've tested this and it works
Regards
根据我的经验,一次性安装所有 R 软件包并不明智!即使您不调用(使用库函数)所有这些包,只要放在主目录中,它们也会减慢您的 R 工作室的速度。至少我的例子就是这样。
From my experience, it is not wise to install all the R packages at once! Even if you do not call upon (using library function) all those packages, by just sitting in the home directory, they can slow down your R studio. At least that's what happened in my case.