[R] Upgrade process for libraries: can I use installed.packages on an old installation followed by install.packages in a new one

Gabor Grothendieck ggrothendieck at gmail.com
Fri Apr 30 00:28:41 CEST 2010


The batchfiles distribution has a copydir.bat which copies files from
one directory to another without overwriting anything and a
movedir.bat which is similar but moves the files rather than copying
them (which is much faster but you wont have the packages in your old
installation any more).

Get the batchfiles distribution from http://batchfiles.googlecode.com
(this is not an R package) and from it get either copydir.bat or
movedir.bat depending on whether you want to copy or move your
packages from one library to another.  Either is a self contained
batchfile so just put it anywhere in your PATH.  Neither of these will
overwrite anything but can be used to copy or move the ones that do
not already exist in the target library.  The example below assumes
you use the R defaults for win-library:

  :: first, download and install R-2.11.0
  :: now perform the next two commands at the Windows console

  cd %userprofile%\Documents\R\win-library
  :: you can use movedir instead of copydir if you prefer to move them
  copydir R-2.10.1\library R-2.11.0\library

  :: ... now startup new version of R (R 2.11.0 in this example)
  # issue this command in R 2.11.0
  update.packages(checkBuilt = TRUE, ask = "graphics")

On Thu, Apr 29, 2010 at 6:12 PM, Ted Byers <r.ted.byers at gmail.com> wrote:
> When doing a fresh install of a new version of R, using update.packages()
> requires copying some of the contents of the library subdirectory to the new
> installation.  While possible and viable, it can be problematic in being
> tedious (more an irritation regarding how Windows handles copying
> directories from one location to another when there are already things in
> the target directory with the same names, than anything else), and there
> exists the possibility that there are some old packages that are obsolete
> and won't work properly in the new version.
>
> I don't suppose update.packages() will remove obsolete packages in the
> library directory if it finds them, does it?
>
> I have a preference for trying to do a fresh install of a given product's
> optional packages (so if a given package has a problem in the new version,
> it just doesn't install - rather than cluttering its directory tree with
> useless stuff); something that is trivially easy if looking at only a
> handful of optional packages but very tedious when there are so many.  I
> know from experience that repeatedly having a large, complex piece of
> software, whether a major application (like R or MS Word, &c.) or an OS like
> Windows, update/over-write key part of itself will eventually lead to hard
> to diagnose problems.  It is often good to have more than one way to
> accomplish a given task, and there are usually many options to choose from
> when designing/implementing software.
>
> Actually, with the benefit of 20/20 hindsight, if I had been asked to write
> a update.packages() function, I would have had it look in the registery on
> Windows, or in the directory tree, for evidence of an older version of R
> (perhaps a version that is used only during a fresh install of R), and have
> it process the list of detected packages and install/upgrade any packages
> that will work with the new version of R, and perhaps, if a given obsolete
> package has been superceded by something else, make sure that 'something
> else' is installed instead, just so the directory tree for the new install
> is not cluttered with old, potentially broken, stuff.
>
> Thanks
>
> Ted
>
> On Thu, Apr 29, 2010 at 4:59 PM, Erik Iverson <eriki at ccbr.umn.edu> wrote:
>
>>
>>
>> Ted Byers wrote:
>>
>>> I tend to have a lot of packages installed, in part because of a wide
>>> diversity of interests and a disposition of examining different ways to
>>> accomplish a given task.
>>>
>>> I am looking for a better way to upgrade all my packages when I upgrade
>>> the
>>> version of R that I am running.
>>>
>>> On looking at support for installing and updating packages, I found these
>>> two: installed.packages() and  install.packages() and it occurred to me
>>> that
>>> in principle I ought to be able to use the one in the original
>>> installation
>>> to get a list of packages I'm working with and and put its output into a
>>> plain text file that I can read in the new installation and pass to the
>>> other to ensure the new installation has a fresh installation of all the
>>> packages I want to work with.
>>>
>>
>> I must be missing the obvious, but what's wrong with update.packages() ?
>>
>
>
>
> --
> R.E.(Ted) Byers, Ph.D.,Ed.D.
> TED at MERCHANTSERVICECORP.COM
> CTO
> Merchant Services Corp.
> 350 Harry Walker Parkway North, Suite 8
> Newmarket, Ontario
> L3Y 8L3
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list