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.