Created
March 31, 2017 08:54
-
-
Save shravan-kuchkula/48a70d279cd292ea5831012be1b360f9 to your computer and use it in GitHub Desktop.
Install and load packages in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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