Install Specific Packages
Ref: Installing Packages without Internet
On the online host:
getDependencies <- function(packs){
dependencyNames <- unlist(
tools::package_dependencies(packages = packs, db = available.packages(),
which = c("Depends", "Imports"),
recursive = TRUE))
packageNames <- union(packs, dependencyNames)
packageNames
}
pkgs <- c("digest", "plyr", "reshape2")
packages <- getDependencies(pkgs)
setwd('~/temp/myrepo/')
pkgInfo <- download.packages(pkgs = packages, destdir = getwd(), type = "source")
write.csv(file = "pkgFilenames.csv", basename(pkgInfo[, 2]), row.names = FALSE)
library(tools)
write_PACKAGES()
Copy ~/temp/myrepo to the folder /vagrant/myrepo on production host and run:
setwd('/vagrant/myrepo/')
pkgFilenames <- read.csv("pkgFilenames.csv", stringsAsFactors = FALSE)[, 1]
install.packages(pkgFilenames, repos = NULL) # if failed, run the command below
install.packages("plyr", contriburl="file:///vagrant/myrepo/")
via miniCRAN
Not work.
$ sudo apt install libssl-dev libxml2-dev
> install.packages("miniCRAN")
But function pkgDep()
failed.
Backup All CRAN Repos
via wget
Ref: Offline install of R package and dependencies
Download R packages to a online host: wget 'ftp://cran.r-project.org/pub/R/src/contrib/*.tar.gz'
. Or download part by part: for i in U u V v W; wget "ftp://cran.r-project.org/pub/R/src/contrib/$i*.tar.gz"
(for zsh) or for i in U u; do wget "ftp://cran.r-project.org/pub/R/src/contrib/$i*.tar.gz"; done
(for bash).
But the digest source file is absent. It seems not all source files are downloaded. And this method is not reliable.
via download.packages
Not test yet.
Ref: R Package Automated Download
> pkg.list = available.packages()
> download.packages(pkgs = pkg.list, destdir = "C:\\MyRPackages")