LoginSignup
1
2

More than 3 years have passed since last update.

miniCRANを使ってみたメモ

Posted at

「インターネットに接続できない環境があって、そこにCRANパッケージをインストールしたい時にどうしたらいいんだっけ?」と思って調べたら、miniCRANに辿り着いたので、メモを残しておく。

Disclaimer

公式ドキュメントとブログに書かれてることしかやってないです。違いは国内のミラーを使っているくらい?

インストール

install.packages("miniCRAN")

レポジトリをつくる

library(miniCRAN)

# Use mirror in Japan
repo <- c(CRAN = "https://cran.ism.ac.jp/")
pkgs <- c("ggplot2")
pkgList <- pkgDep(pkgs, repos = repo, type = "source", suggests = FALSE)
pkgList

# Create temporary folder for miniCRAN
dir.create(pth <- file.path(tempdir(), "miniCRAN"))

# Make repo for source, win.binary and mac.binary.el-capitan
makeRepo(pkgList, path=pth, repos=repo, type=c("source", "win.binary", "mac.binary.el-capitan"))

# List all files in miniCRAN
list.files(pth, recursive = TRUE, full.names = FALSE)

# Check for available packages
pkgAvail(repos = pth, type="mac.binary.el-capitan")

ローカルからインストールする

install.packages(pkgs, repos=paste0("file:///", pth), type = "source")
1
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
1
2