Reputation: 29
I have all the packages in tgz and i want to install sparklyr:
install.packages(pkgs = "sparklyr_0.9.2.tar.gz",
lib = getwd(),
verbose = T,
repos = NULL,
dependencies = TRUE)
system (cmd0): /opt/cloudera/extras/R-3.3.1/lib/R/bin/R CMD INSTALL
ERROR: dependencies ‘broom’, ‘r2d3’, ‘purrr’, ‘forge’ are not available for package ‘sparklyr’
* removing ‘/home/afranco/Paquetes/sparklyr’
but in the same folder I have the packages ‘broom’, ‘r2d3’, ‘purrr’, ‘forge’. So I want to install some packges using this method but I dont have any kind of internet connection.
Upvotes: 0
Views: 2248
Reputation: 539
The instructions in the r-bloggers post will give you all the info you need: How to install packages without internet
Here is the part about dependencies:
In the Office: Download the Dependencies Knowing the packages we need is one thing, but knowing which packages they depend on is another, and knowing which packages those dependencies depend on is… well, not worth thinking about – there’s a function that comes with R to do it for us called package_dependencies().
Here’s a short example script that uses package_dependencies() to figure out the dependencies from the packages we want to use.
#' Get package dependencies
#'
#' @param packs A string vector of package names
#'
#' @return A string vector with packs plus the names of any dependencies
getDependencies <- function(packs){
dependencyNames <- unlist(
tools::package_dependencies(packages = packs, db = available.packages(),
which = c("Depends", "Imports"),
recursive = TRUE))
packageNames <- union(packs, dependencyNames)
packageNames
}
# Calculate dependencies
packages <- getDependencies(c("tidyverse", "mangoTraining"))
We can then download the right package type for the environment we’re going to be training. Often our customers are on Windows so we would download the “win.binary” type. We’re also going to save the package file names too so that we can install them by filename later.
# Download the packages to the working directory.
# Package names and filenames are returned in a matrix.
setwd("D:/my_usb/packages/")
pkgInfo <- download.packages(pkgs = packages, destdir = getwd(), type = "win.binary")
# Save just the package file names (basename() strips off the full paths leaving just the filename)
write.csv(file = "pkgFilenames.csv", basename(pkgInfo[, 2]), row.names = FALSE)
On Site: Install the Packages Assuming we’ve downloaded our packages to a USB stick or similar, on site and without an internet connection we can now install the packages from disk.
# Set working directory to the location of the package files
setwd("D:/my_usb/packages/")
# Read the package filenames and install
pkgFilenames <- read.csv("pkgFilenames.csv", stringsAsFactors = FALSE)[, 1]
install.packages(pkgFilenames, repos = NULL, type = "win.binary")
Upvotes: 1