> On 29 Nov 2017, at 15:28, Larry Martell <larry.mart...@gmail.com> wrote: > > I have a R script that I call from python using rpy2. It uses dplyr, doBy, > and ggplot2. The script has install.packages commands for these 3 packages. > Even thought the packages are already installed it still downloads, > builds, and installs them, which is very time consuming. Is there a way to > have it only do the install if the package is not already installed?
You could use something like if (!require(dplyr)) { install.packages(“dplyr”) library(dplyr) } where require() returns FALSE if it fails to load the package. > > Also, I run in a docker container, so after the container is instantiated > the packages are not there the first time the script runs. Is there a way > to pre load the packages, in which case I would not need the > install.packages commands for these packages and my above question would > become moot. Yes - add them to you Docker file, but this is a docker question, not R. Check out the Rocker Dockerfiles to see how you can do this. Rainer > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany) University of Zürich Cell: +41 (0)78 630 66 57 email: rai...@krugs.de Skype: RMkrug PGP: 0x0F52F982
signature.asc
Description: Message signed with OpenPGP
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.