Last active
June 2, 2016 02:46
-
-
Save yamano357/0a32055f5a201296655c1f71c0bbbae7 to your computer and use it in GitHub Desktop.
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
# CRANにあるパッケージをまとめてインストール | |
# 関数定義部 ----------------------------------------------------------------------- | |
# CRAN設定 | |
SET_CRAN <- list( | |
REPOS = "http://cran.r-project.org", | |
RDS = "src/contrib/Views.rds" | |
) | |
# インストール対象のTASK VIEW | |
SET_TASK_VIEW <- c("Bayesian", "Econometrics", "Cluster", "Distributions", "Econometrics", "Finance", "Graphics", "NumericalMathematics", "HighPerformanceComputing", "MachineLearning", "Multivariate", "NaturalLanguageProcessing", "Optimization", "ReproducibleResearch", "Robust", "SocialSciences", "Spatial", "Survival", "TimeSeries", "WebTechnologies", "gR") | |
# 実行部 ----------------------------------------------------------------------- | |
# 取得したRDSファイルを読み込みインストール候補となるパッケージ名を取得 | |
# (TASK VIEW間で重複するパッケージをまとめる) | |
view_filename <- basename(path = paste(SET_CRAN$REPOS, SET_CRAN$RDS, sep = "/")) | |
download.file( | |
url = paste(SET_CRAN$REPOS, SET_CRAN$RDS, sep = "/"), | |
destfile = view_filename, | |
mode = "wb" | |
) | |
taskview <- readRDS(file = gzfile(description = view_filename)) | |
taskview_packages <- unique( | |
x = do.call( | |
what = "rbind", | |
args = lapply( | |
X = taskview[is.element(el = sapply(X = taskview, FUN = "[[", "name"), set = SET_TASK_VIEW)], | |
FUN = "[[", "packagelist" | |
) | |
)$name | |
) | |
# パッケージインストール | |
cond_inst_packages <- setdiff( | |
x = taskview_packages, y = rownames(x = installed.packages()) | |
) | |
install.packages( | |
pkgs = cond_inst_packages, | |
type = "source", repo = SET_CRAN$REPOS | |
) | |
# 確認 | |
setdiff(x = cond_inst_packages, y = rownames(x = installed.packages())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment