Helmut Kudrnovsky
2005-Dec-23 14:43 UTC
[R] copy contributed packages from R 2.2.0 to 2.2.1
hi R-users, a few days ago R 2.2.1 came out. on my win xp i'installed R 2.2.0. along the time i've installed a lot of contributed packages. my internet-connection is not very fast. so my question: is it possible after installing R 2.2.1 to do copy/paste the contributed packages from the C:\Programme\R221 to the C:\Programme\R2.2.1- location in the files system? or have i to download and install the packages new? greetings from the snowy austria merry christmas helli system R.2.2.0 win xp
Ronnie Babigumira
2005-Dec-23 14:58 UTC
[R] copy contributed packages from R 2.2.0 to 2.2.1
Hi Helli, this came up last week, Here are some of the replys posted 1. In http://cran.r-project.org/contrib/extra/batchfiles/batchfiles_0.2-5.zip are two Windows XP batch files: movedir.bat copydir.bat which will move the packages (which is much faster and suitable if you don't need the old version of R any more) or copy the packages (which takes longer but preserves the old version). 2. x <- installed.packages()[,1] install.packages(x) 3. This is one reason we normally recommend that you install into a separate library. Then update.packages(checkBuilt = TRUE) is all that is needed. However, foo <- installed.packages() as.vector(foo[is.na(foo[, "Priority"]), 1]) will give you a character vector which you can feed to install.packages(), so it's not complex to do manually. 4. If the previous installation is still alive, fire it up and pS <- packageStatus() pkgs <- pS$inst$Package[!pS$inst$Priority %in% c("base", "recommended")] save(pkgs, file = "foo") In the new installation, load("foo") install.packages(pkgs) Helmut Kudrnovsky wrote:> hi R-users, > > a few days ago R 2.2.1 came out. on my win xp i'installed R 2.2.0. along the time i've installed a lot of contributed packages. my internet-connection is not very fast. > > so my question: is it possible after installing R 2.2.1 to do copy/paste the contributed packages from the C:\Programme\R221 to the C:\Programme\R2.2.1- location in the files system? > > or have i to download and install the packages new? > > > greetings from the snowy austria > merry christmas > helli > > system > R.2.2.0 > win xp > > ______________________________________________ > 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 >
Helmut Kudrnovsky wrote:> hi R-users, > > a few days ago R 2.2.1 came out. on my win xp i'installed R 2.2.0. along the time i've installed a lot of contributed packages. my internet-connection is not very fast. > > so my question: is it possible after installing R 2.2.1 to do copy/paste the contributed packages from the C:\Programme\R221 to the C:\Programme\R2.2.1- location in the files system?It is safe to copy. Uwe Ligges> > or have i to download and install the packages new? > > > greetings from the snowy austria > merry christmas > helli > > system > R.2.2.0 > win xp > > ______________________________________________ > 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
When I asked this question, I got some good answers. Based on them, I wrote a pair of functions to accomplish this. I have tested them in exactly ONE installation, and they worked. Of course these are not needed by R gurus, but I attach them (with many more comment lines than actual source) for the use of anyone else who would like to use them. MHP Helmut Kudrnovsky wrote on 12/23/2005 9:43 AM:>hi R-users, > >a few days ago R 2.2.1 came out. on my win xp i'installed R 2.2.0. along the time i've installed a lot of contributed packages. my internet-connection is not very fast. > > so my question: is it possible after installing R 2.2.1 to do copy/paste the contributed packages from the C:\Programme\R221 to the C:\Programme\R2.2.1- location in the files system? > >or have i to download and install the packages new? > > >################################################################################## # Functions to (1) save names of installed package from an R installation to # # a file and (2) install the same packages on a new R installation. # ################################################################################## # HOW TO MOVE PACKAGES FROM ONE R INSTALLATION TO ANOTHER: # # Put this file in your R working directory. Source it. Run SaveMyPackages() # # under the old installation. Save your workspace and exit. Open the new # # installation on the same directory. Run InstallMyPackages(). The packages # # will be installed. You may now rm(SaveMyPackages,InstallMyPackages) if you # # like. Also, you may delete the file "pkg.list" in the working directory. # ################################################################################## # M. H. Prager mike.prager at noaa.gov # # with much from posted code of U. Ligges, H. Nilsson, & B. Ripley # # December, 2005 # ################################################################################## SaveMyPackages <- function(filename = "pkg.list", savepkg = TRUE) { # Saves a character vector with names of non-default # packages installed. Writes it to a "dput" ASCII file. # ---> Run this from "old" installation. <--- # Arguments: # filename -- Character, name of file to write. # savepkg -- Logical, if TRUE save the file; if not, return # the vector of package names instead. foo <- installed.packages() foo <- as.vector(foo[is.na(foo[, "Priority"]), 1]) if (savepkg) dput(foo, file = filename) else return(foo) } InstallMyPackages <- function(x = dget(file = filename), filename = "pkg.list", install = TRUE) { # Install or print list of packages . # ---> Run this from "new" installation. <--- # Arguments: # x-- character, contains names of packages to install; default is # vector read from argument "filename". # filename-- character, name of file containing vector (in dput format); # default is "pkg.list" as in SaveMyPackages. # install-- logical, should actual installation be done? If not, # the vector of package names in x is returned instead # of being installed. if (install) install.packages(x) else return(x) } ##################################################################################