Offline install of R package and dependencies
The correct answer was given by Joshua Ulrich in the comment on the question:
The key is prefixing the argument to either repos
or contriburl
with file://
. So in Unixy systems one could do:
install.packages("ggplot2", contriburl="file:///path/to/packages/")
This assumes that all required source packages, as well as a PACKAGES index file is available in /path/to/packages
. If no PACKAGES file is present, this should be generated first using:
library(tools)
write_PACKAGES("/path/to/packages/")
which will generate an index of all source packages found in this directory. Note that in the example, there are 3 slashes behind the file:
prefix. The third slash indicates a path relative to the root of the file system.
The difference between the repos
and contriburl
argument is that repos
will append another /src/contrib
to the path specified, as this is usually where source packages are located on an official CRAN repository mirror.
R script: Installing packages from offline miniCRAN, still tries to access internet
My bad. The script should look like this:
install.packages('yaImpute',
repos = paste0("file:///", "C:/Temp/miniCRAN/"),
type = "source")
R: How do I install packages and dependencies offline
I would suggest miniCRAN
and specifically the pkgDep
function to take care of all the dependency stuff. For example
library(miniCRAN)
pkgs <- c("tidyverse", "data.table", "RODBC", "RJDBC", "fasttime", "tidyr",
"knitr", "randomForest", "RMySQL", "jsonlite")
pkgList <- pkgDep(pkgs, type = "source", suggests = FALSE)
makeRepo(pkgList, path="/path/to/packages/", type = c("source"))
And then you would install from the repo with
install.packages(pkgs, repos="file://path/to/packages/", type="source")
offline installation of packages in R - empty index file generated
I was able to install the package that I wanted (package name = dplyr
), using the hints in the comments above. I needed to change two things
I downloaded windows binaries instead of
source
files, usingtype = "win.binary"
parameter in thedownload.packages
command.The path in
contriburl = "file:///"
needed to be changed tocontriburl = "file:///<ABSOLUTE_PATH_TO_FOLDER_WITH_WIN_BINARIES>"
With these changes, the package installation went successfully.
Hope it helps others.
SN248
Related Topics
Shiny: Open New Browser Tab from Within Shiny App
Can Ggplot Make 2D Summaries of Data
Change Color Actionbutton Shiny R
Create a Variable Length 'Alist()'
Easiest Way to Discretize Continuous Scales for Ggplot2 Color Scales
Collapse and Merge Overlapping Time Intervals
Format Latitude and Longitude Axis Labels in Ggplot
R/Ggplot2: Collapse or Remove Segment of Y-Axis from Scatter-Plot
How to Save Interactive Charts from Dygraph
What Does Passing an Ellipsis (...) as an Argument Mean in R
Raster Image Goes Below Base Layer, While Markers Stay Above: Xindex Is Ignored
Use a Custom Icon in Plotly's Pie Chart in R
How to Use Aggregate Function in R
How Can a Script Find Itself in R Running from the Command Line