How to install multiple packages? How to install multiple packages? r r

How to install multiple packages?


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

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

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

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

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.


load.lib<-c("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.lib<-load.lib[!load.lib %in% installed.packages()]for(lib in install.lib) install.packages(lib,dependencies=TRUE)sapply(load.lib,require,character=TRUE)


Here is a sweet 🍭 suite of data science packages📦

You will also need to pay attention to make sure you're not using different styled quotation marks that are sometimes created in text editors if you’re using a foreign language.

$ R

> install.packages(c("remotes","readxl","googlesheets","haven", "readr", "rio", "Hmisc", "sqldf", "jsonlite", "XML", "httr", "quantmod", "tidyquant", "rvest", "dplyr", "purrr", "reshape2", "tidyr", "magrittr", "validate", "testthat", "data.table", "stringr", "lubridate", "zoo", "editR", "knitr", "officer", "listviewer", "DT", "ggplot2", "ggiraph", "dygraphs", "googleVis", "metricsgraphics", "RColorBrewer", "sf", "leaflet", "ggmap", "tmap", "tmaptools", "mapsapi", "tidycensus", "glue", "rga", "RSiteCatalyst", "roxygen2", "shiny", "flexdashboard", "openxlsx", "gmodels", "janitor", "car", "rcdimple", "foreach", "scales", "plotly", "highcharter", "profvis", "tidytext", "diffobj", "Prophet", "feather", "fst", "googleAuthR", "cloudyR"))

If you're installing from CLI R will say --- Please select a CRAN mirror for use in this session --- and after a couple of seconds a GUI will pop up and show a list of global download mirrors.

If you're using the latest version of R you might get a warning that certain older packages aren't available for your R version which you can choose to ignore, find newer packages or use an older version of R.

Warning message: packages ‘editR’, ‘rga’, ‘rcdimple’, ‘Prophet’, ‘cloudyR’ are not available (for R version 3.4.2)

The compressed .tgz files will be downloaded somewhere like /private/var/folders/2k/p756_j5x0x5fqplwrq74j1sh0000gn/T/RtmpMTzQQ5/downloaded_packages

Actual packages located in /Users/tymac/Library/R/3.4/library and /Library/Frameworks/R.framework/Versions/3.4/Resources/library.

You can view packages a couple of other ways.

  • Open R app/console
  • --> Help --> Html help
  • Reference --> Packages

or

  • Open RStudio
  • --> Help --> R Help
  • help area
  • --> Reference --> Packages