[R] install.packages, bundles, pmatch, and Rprofile...
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Nov 2 22:08:44 CET 2004
On Tue, 2 Nov 2004, Andy Bunn wrote:
> Hi,
>
> Somebody asked me to make sure that all the machines running the in our lab
> (XP and Linux, both running 2.0) have R installed and that A) All the
> packages are installed and B) kept up-to-date.
>
> Obediently, I began to modify a shared Rprofile so that once a week it
> checks for new packages and updates to the current version of the installed
> packages on CRAN. Sounds simple enough. Plus some general conditioning
> statements to make sure that this runs only once a week or so the logic I'm
> following is:
>
>
> myPackages <- installed.packages()
> CRANsPackages <- CRAN.packages()
> missingPackages <- CRANsPackages[is.na(match(CRANsPackages[,1],
> myPackages[,1])),1]
> install.packages(missingPackages)
>
>
> Now this might be trivial, but, missingPackages includes bundled packages
> which are already installed (e.g., dse, VR) in addition to those packages
> that are truly missing. I know I have to match myPackages with the Contains
> column in CRANsPackages and probably use pmatch to do it, but the syntax
> eludes me.
You do want an exact match.
The code you need is in packageStatus(), so you don't need to reinvent
this particular wheel. Look at its summary() method (and output) to see
how to get what you want.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list