Dear Listers, I am a little tired of installing all packages I want every time when I instill a new version of R. Say, if I have a list of packages I need to use, is it possible to tell R to install them all for me automatically rather than I install them one by one? Thx.
Try ?update.packages Ross Darnell -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Wensui Liu Sent: Tuesday, 11 September 2007 11:45 AM To: r-help at stat.math.ethz.ch Subject: [R] install packages automatically Dear Listers, I am a little tired of installing all packages I want every time when I instill a new version of R. Say, if I have a list of packages I need to use, is it possible to tell R to install them all for me automatically rather than I install them one by one? Thx. ______________________________________________ R-help at stat.math.ethz.ch mailing list 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.
This was discussed here sometime ago. Several variants are possible. You can install the new version of R over the old one, in the same folder, this preserves the installed packages. At least, this works fine for me on Windows. You can also store your list of packages in a simple R script and execute it once every time you upgrade the R version. Something like this: install.packages(c( "AMORE", "ggplot2", "rgdal", "rgl" [etc] )) You can also install these packages into separate directory and add the path to the .libPaths (please, refer to the documentation about library paths). This can be done, for example, in system wide startup script Rprofile.site Wensui Liu wrote:> > Dear Listers, > I am a little tired of installing all packages I want every time when > I instill a new version of R. > Say, if I have a list of packages I need to use, is it possible to > tell R to install them all for me automatically rather than I install > them one by one? > Thx. >-- View this message in context: http://www.nabble.com/install-packages-automatically-tf4419780.html#a12609660 Sent from the R help mailing list archive at Nabble.com.
Hi I use the following method which works well for me. I create a directory to hold the installed packages e.g. C:\Program Files\R\mylibrary Then in my C:\Program Files\R\R-2.5.1\.Renviron file I have a line as follows: R_LIBS=C:/PROGRA~1/R/mylibrary (I think you have to use Windows short names in this file.) Thus whenever I install a new package it is installed in this directory. If I install a new version of R just update the .Renviron file and run Packages->Update packages ... This keeps the R base packages separate from the optional packages. JS --- -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Wensui Liu Sent: 11 September 2007 02:45 To: r-help at stat.math.ethz.ch Subject: [R] install packages automatically Dear Listers, I am a little tired of installing all packages I want every time when I instill a new version of R. Say, if I have a list of packages I need to use, is it possible to tell R to install them all for me automatically rather than I install them one by one? Thx. ______________________________________________ R-help at stat.math.ethz.ch mailing list 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.
I think using R_LIBS_USER is better.>From ?.libPaths:The library search path is initialized at startup from the environment variable R_LIBS (which should be a semicolon-separated list of directories at which R library trees are rooted) followed by those in environment variable R_LIBS_USER. john seers (IFR) wrote:> > I use the following method which works well for me. > > I create a directory to hold the installed packages e.g. C:\Program > Files\R\mylibrary > > Then in my C:\Program Files\R\R-2.5.1\.Renviron file I have a line as > follows: > > R_LIBS=C:/PROGRA~1/R/mylibrary > > (I think you have to use Windows short names in this file.) > > Thus whenever I install a new package it is installed in this directory. > If I install a new version of R just update the .Renviron file and run > Packages->Update packages ... > > This keeps the R base packages separate from the optional packages. > JS > -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > Subject: [R] install packages automatically > > Dear Listers, > I am a little tired of installing all packages I want every time when I > instill a new version of R. > Say, if I have a list of packages I need to use, is it possible to tell > R to install them all for me automatically rather than I install them > one by one? > Thx. > >-- View this message in context: http://www.nabble.com/install-packages-automatically-tf4419780.html#a12610798 Sent from the R help mailing list archive at Nabble.com.
Hi Vladimir You may well be right and it is better, or at least better practice. But I have a feeling I tried it and it was not as successful, but I cannot remember why. Perhaps it was because when installing new packages they were not installed in that (USER) directory? JS -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Vladimir Eremeev Sent: 11 September 2007 10:10 To: r-help at stat.math.ethz.ch Subject: Re: [R] install packages automatically I think using R_LIBS_USER is better.>From ?.libPaths:The library search path is initialized at startup from the environment variable R_LIBS (which should be a semicolon-separated list of directories at which R library trees are rooted) followed by those in environment variable R_LIBS_USER. john seers (IFR) wrote:> > I use the following method which works well for me. > > I create a directory to hold the installed packages e.g. C:\Program > Files\R\mylibrary > > Then in my C:\Program Files\R\R-2.5.1\.Renviron file I have a line as > follows: > > R_LIBS=C:/PROGRA~1/R/mylibrary > > (I think you have to use Windows short names in this file.) > > Thus whenever I install a new package it is installed in thisdirectory.> If I install a new version of R just update the .Renviron file and run > Packages->Update packages ... > > This keeps the R base packages separate from the optional packages. > JS > -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > Subject: [R] install packages automatically > > Dear Listers, > I am a little tired of installing all packages I want every time whenI> instill a new version of R. > Say, if I have a list of packages I need to use, is it possible totell> R to install them all for me automatically rather than I install them > one by one? > Thx. > >-- View this message in context: http://www.nabble.com/install-packages-automatically-tf4419780.html#a126 10798 Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help at r-project.org mailing list 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.