Re: [R] Preventing repeated package installation, or pre installing packages
On Wed, Nov 29, 2017 at 11:20 AM, Thierry Onkelinxwrote: > Dear Larry, > > Have a look at https://github.com/inbo/rstable That is a dockerfile > with a stable version of R and a set of packages. Thank you very much. This is very useful to me. > 2017-11-29 15:28 GMT+01:00 Larry Martell : >> 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? >> >> 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. >> >> [[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. __ 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.
Re: [R] Preventing repeated package installation, or pre installing packages
On Wed, Nov 29, 2017 at 11:14 AM, Rainer Krugwrote: > > > On 29 Nov 2017, at 15:28, Larry Martell 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. Thanks that worked perfectly. > 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. What I did not know was how to load a R package from the command line. Thanks to Thierry Onkelinx's answer I now do know. __ 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.
Re: [R] Preventing repeated package installation, or pre installing packages
Dear Larry, Have a look at https://github.com/inbo/rstable That is a dockerfile with a stable version of R and a set of packages. Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance thierry.onkel...@inbo.be Kliniekstraat 25, B-1070 Brussel www.inbo.be /// To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey /// Van 14 tot en met 19 december 2017 verhuizen we uit onze vestiging in Brussel naar het Herman Teirlinckgebouw op de site Thurn & Taxis. Vanaf dan ben je welkom op het nieuwe adres: Havenlaan 88 bus 73, 1000 Brussel. /// 2017-11-29 15:28 GMT+01:00 Larry Martell: > 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? > > 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. > > [[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. __ 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.
Re: [R] Preventing repeated package installation, or pre installing packages
> On 29 Nov 2017, at 15:28, Larry Martellwrote: > > 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.
Re: [R] Preventing repeated package installation, or pre installing packages
Dear Larry As far as your first question is concerned I think one of require or requireNamespace may be what you need. Michael On 29/11/2017 14:28, Larry Martell 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? 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. [[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. -- Michael http://www.dewey.myzen.co.uk/home.html __ 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.