I am installing packages based on a Docker file in a machine with very small storage capacities.
My question is whether there is any way to install a more lightweight version of R packages that avoids non-critical bits of the package for deployed code such as the documentation.
Is there a way to do this through install.packages
?
Otherwise, is there any other way to do it?
You can manually specify what you'd like to have installed, for example:
R CMD INSTALL [options] <package-name>
or with install.packages("package-name", INSTALL_opts = c("--option1", "--option2"))
where relevant options for your case might be the following:
--no-docs do not install HTML, LaTeX or examples help
--no-html do not build HTML help
--no-R, --no-libs, --no-data, --no-help, --no-demo, --no-exec,
--no-inst
suppress installation of the specified part of the
package for testing or other special purposes
--libs-only only install the libs directory
--data-compress= none, gzip (default), bzip2 or xz compression
to be used for lazy-loading of data
--resave-data re-save data files as compactly as possible
--compact-docs re-compress PDF files under inst/doc
Alternatively you could use install2.r
from the littler
package as described here as a simple way to ensure that building is quitted if an error occurrs or to choose whether you'd also like to include dependencies.
Regarding a lightweight installation, and corresponding to the suggestion by Mat D., you could use littler
and docopt
packages in combination with install2.r
. Besides the options that are provided, you can also include
R CMD INSTALL
arguments. The procedure is described here
When the library location (libloc) is set, you can use docopt
to specify the desired installation details.
For instance, install2.r -n 4 ggplot2 --no-html
will allow parallel installation using 4 processes and install ggplot2
without HTML help. You can specify an individual installation process for each desired package whereas dependencies are set to NA
by default.
© 2022 - 2024 — McMap. All rights reserved.
R
. – Gharry