I recently had a problem where I wanted to download all dependencies and I've solved it thus:
Say I want all the dependencies and imports of ggplot2
and MASS
:
getPackages <- function(packs){
packages <- unlist(
tools::package_dependencies(packs, available.packages(),
which=c("Depends", "Imports"), recursive=TRUE)
)
packages <- union(packs, packages)
packages
}
packages <- getPackages(c("ggplot2", "MASS"))
I can now download the packages to another directory.
download.packages(packages, destdir="whereyouactuallywantthefiles",
type="source")
From there if you want to make a local repo on your Linux PC, follow the instructions here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…