Skip to content

Instantly share code, notes, and snippets.

@shravan-kuchkula
Created March 31, 2017 08:54
Show Gist options
  • Save shravan-kuchkula/48a70d279cd292ea5831012be1b360f9 to your computer and use it in GitHub Desktop.
Save shravan-kuchkula/48a70d279cd292ea5831012be1b360f9 to your computer and use it in GitHub Desktop.
Install and load packages in R
# Install a package and load it.
installRequiredPackages <- function(pkg){
new.pkg <- pkg[!(pkg %in% installed.packages()[,"Package"])]
if (length(new.pkg))
install.packages(new.pkg, dependencies = TRUE)
sapply(pkg, require, character.only = TRUE)
}
libs <- c("readr", "dplyr", "tidyr", "ggplot2",
"magrittr", "markdown", "knitr", "Hmisc",
"repmis", "yaml", "psych", "lsr")
installRequiredPackages(libs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment