Skip to content

Instantly share code, notes, and snippets.

@DeepanshKhurana
Created January 17, 2019 09:41
Show Gist options
  • Save DeepanshKhurana/2dbe53ef9f512d407c55c039ac95308f to your computer and use it in GitHub Desktop.
Save DeepanshKhurana/2dbe53ef9f512d407c55c039ac95308f to your computer and use it in GitHub Desktop.
A simple script to quickly install R packages on R and R Studio based on categories
# This script will let you choose R packages. There's a mechanism to check whether the package is already installed, and it will print a # statement with the package name if it is installed.
# This can also serve as a handy list for the
# Linux Dependencies: libssl-dev, libcurl4-openssl-dev and libxml2-dev, unixodbc-dev
wrangling <- c("tidyverse", "gsubfn", "googlesheets", "stringr", "stringi", "readr", "data.table", "lubridate")
analysis <- c("MASS", "caret", "CARS", "sqldf")
graphics <- c("ggmap", "gridExtra", "RColorBrewer", "scales", "plotly") #ggplot2 is done in tidyverse
sql <- c("RSQLite", "odbc")
python <- c("reticulate")
github <- c("githubinstall", "devtools)
utilities <- c("RCurl")
json <- c("rjson", "jsonlite")
all <- c(wrangling, analysis, graphics, sql, python, github, utilities, json)
is.installed <- function(mypkg){
is.element(mypkg, installed.packages()[,1])
}
# Change this for package type
# package_type = json
# use "all" for all utilities above
package_type = all
# If tidyverse fails to install
# install.packages("readr", INSTALL_opts = c('--no-lock'))
for(package in package_type) {
if (!is.installed(package)) {
install.packages(package, dependencies = TRUE)
}
else {
cat("\"", package, "\" is already installed.\n", sep = "")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment