2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[R] パッケージの一括インストール・ロード (CRAN, Bioconductor)

Last updated at Posted at 2019-10-16

R(v3.5以上)のパッケージを一括でインストール・ロードするためのスクリプトのメモです。

p_loadを使う(おすすめ)

pacmanp_load関数を使うと、CRANだけでなくBioconductorからもインストールとロードができます。

options(repos = "https://cran.ism.ac.jp/")
if (!requireNamespace("pacman", quietly = T)) install.packages("pacman")
if (!requireNamespace("BiocManager", quietly = T)) install.packages("BiocManager")
pacman::p_load(tidyverse, SpectralTAD)

BiocManagerを使う

BiocManagerを用いるとCRAN/Bioconductor/GitHubの
リポジトリからパッケージをインストールすることができます。

# もしBiocManagerのバージョンが古い場合は一旦削除します。
# remove.packages("BiocVersion") 

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

pkgs <- c("tidyverse","rstan", "edgeR")

for(pkg in pkgs) if (!require(pkg, character.only = T)){
    BiocManager::install(pkg, update = F)
    require(pkg, character.only = T)
}

以前はCRANはinstall.pacages()、BioconductorからはbiocLite()
別の関数を使う必要がありましたが、BiocManager::installで一括できるのは便利です。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?