I am looking for a function, that downloads an r package zip/tar.gz file (given its name) without installing it.
Basically install.packages()
, but I want to keep the zip files at a given directory.
I did not find a way to build the URL myself given the package Name, but there seems to be one, since install.packages()
works that way.
7-Zip can also be used to unpack many other formats and to create tar files (amongst others).
Using download.packages
:
download.packages(pkgs = "ggplot2", destdir = "/path/to/my/libs")
Or we can get the url manually using available.packages
:
myPackage <- "ggplot2"
p <- available.packages()
myPackageUrl <- paste0(
p[ rownames(p) == myPackage, "Repository"], "/",
myPackage, "_",
p[ rownames(p) == myPackage, "Version"], ".tar.gz")
myPackageUrl
# [1] "https://cran.rstudio.com/src/contrib/ggplot2_2.2.1.tar.gz"
# then download
download.file(url = myPackageUrl,
destfile = paste0("/path/to/my/libs", "/",
basename(myPackageUrl)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With