3

I need to script the install of some R libraries on an offline system. I do possess the source library files I need as I did the install.packages() from within R on a test system that was online, I saved the downloaded source tar.gz files which included all the dependencies of that library as well.

On the test system that's offline, normally I'd install an R library on the Linux command Linux command line like this, ex:

R CMD INSTALL ggplot2_0.9.3.1.tar.gz

But that only seems to work with packages that have no unmet dependencies. I was hoping by putting all the dependencies in the same folder, it would also install those dependency libraries it needed automatically like install.packages() does but this is not the case as it complained:

[root@new-host-15 extra]# R CMD INSTALL ggplot2_0.9.3.1.tar.gz
* installing to library ‘/usr/lib64/R/library’
ERROR: dependencies ‘plyr’, ‘digest’, ‘gtable’, ‘reshape2’, ‘scales’, ‘proto’ are not available for package ‘ggplot2’
* removing ‘/usr/lib64/R/library/ggplot2’

My initial thoughts were I would need to install the other dependencies in order with additional R CMD INSTALL commands but that's a lot of extra commands I would like to avoid if possible. Is there an automatic way to install ggplot2 for example and have all the dependencies which I do have the files for in the same folder also installed automatically without having to specify them individually?

rcs
  • 67,191
  • 22
  • 172
  • 153
ryuken
  • 85
  • 2
  • 7
  • 1
    A few years too late and question is closed, but you can execute R commands directly from your base shell using `R -e 'R code here'`. For example, `R -e 'install.packages("ggplot2")'`. This will cause the default intro text to print as well, so you may want to add a line with `;` as a command break to suppress it. – Alex Firsov Apr 30 '20 at 18:59

1 Answers1

1

From the R shell, you can install.packages(pkgs, repos = NULL) to force the dependency to look for the required tar.gz files locally. Furthermore, you can specify the contriburl attribute to point to the the local file path of the dependent packages. For example install.packages("zoo", contriburl="file:///R/packages/")

http://stat.ethz.ch/R-manual/R-patched/library/utils/html/install.packages.html

NoelProf
  • 865
  • 7
  • 7