From ripley at stats.ox.ac.uk  Fri May 12 15:16:00 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri, 12 May 2006 14:16:00 +0100 (BST)
Subject: [Rd] Dropping dimnames doesn't matter (anymore)?
In-Reply-To: <m08xp7cssk.fsf@bar.nemo-project.org>
References: <m08xp7cssk.fsf@bar.nemo-project.org>
Message-ID: <Pine.LNX.4.64.0605121414040.22390@gannet.stats.ox.ac.uk>

On Fri, 12 May 2006, Bj?rn-Helge Mevik wrote:

> In the "old days", one way of speeding up matrix calculations was to
> drop the dimnames of the matrices prior to the calculations, i.e.,
> dimnames(X) <- NULL.  I distinctly remember that this could have a
> great impact at least in Splus 3.x (under UNIX/Linux).
>
> I just did a small, informal test of this with a couple of functions I
> use to fit plsr models, in R 2.3.0 (Linux).  It didn't seem to have
> any effect at all (the functions actually ran a tiny bit slower,
> probably due to the "dimnames(X) <- NULL" command).
>
> Is the "general rule-of-thumb" with current R versions that the
> overhead of keeping the dimnames through calculations is negligible?

It depends on whether the dimnames are an appreciable part of the size of 
the object.  If they are (e.g. a nx1 array for large n) then manipulating 
them will add an appeciable overhead.  (BTW, character vectors such as 
dimnames are faster in R for some operations but take much more memory.)

-- 
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


[Rd] Dropping dimnames doesn't matter (anymore)?
Prof Brian Ripley