如何安装多个包? [英] How to install multiple packages?

查看:64
本文介绍了如何安装多个包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 R 中安装多个包?

How would I got about installing multiple packages in R?

我尝试了以下代码:

install.packages("EIAdata", "gdata", "ggmap", "ggplot2","gridExtra","ISOweek","kobe","lubridate","maps","MASS","memisc","pander","plyr","psych","Quandl","quantmod","reshape2","rgeos","Rgnuplot","RODBC","scales","sp","sqldf","stockPortfolio","stringi","stringr","XLConnect", "xlsReadWrite","zipcode")

此代码有效:

install.packages("ggplot2")

为什么多个包的行不行?

Why won't the line with the multiple packages work?

推荐答案

Elementary: 通过 c(...) 形成一个向量:

Elementary: form a vector via c(...):

 install.packages(c("EIAdata", "gdata", "ggmap", "ggplot2")) # rest omitted

所以你有 一个长度> 1的第一个参数.

so that you have one first argument of length > 1.

就个人而言,我更喜欢 littler 中的 install.r所以我会这样做(在 Unix 命令行):

Personally, I prefer install.r from littler so I'd do (at the Unix command-line):

  install.r EIAdata gdata ggmap ggplot2    # rest omitted again

请注意,参数的数量没有限制.对我来说,用四个包来写这个比你的例子中的 20 个包更容易.

Note that there is no limit to the number of arguments. It was just easier for me to write this with four packages than the 20-some from your example.

这篇关于如何安装多个包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆