Skip to content

Instantly share code, notes, and snippets.

@3100
Last active August 29, 2015 14:05
Show Gist options
  • Save 3100/b4c89a919318fc0f513a to your computer and use it in GitHub Desktop.
Save 3100/b4c89a919318fc0f513a to your computer and use it in GitHub Desktop.
Install all needed packages and load all in R
InstallPackages <- function(packages, repos) {
# インストールされていないパッケージをインストールします。
#
# Args:
# packages: 必要パッケージ一覧
new.packages <- packages[!(packages %in% installed.packages()[, "Package"])]
if(length(new.packages)) install.packages(new.packages, repos = repos)
for(package in packages) {
do.call("library", list(package = package))
}
}
# packages <- c('grid', 'gplot2', 'RANN')
# repos <- 'http://cran.ism.ac.jp/'
# InstallPackages(packages, repos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment