[Rd] colnames(tapply(...)) (PR#8539)

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Jan 30 09:45:18 CET 2006


On Mon, 30 Jan 2006 karl.thomaseth at isib.cnr.it wrote:

> I would like to bring to your attention the following error message
> which didn't appear on previous versions (long time ago?)
>
> Thanks for all your effort
>
> Karl
>
> Version 2.2.1 Patched (2006-01-21 r37153)
>
> > f <- rep(c(1,2),each=5)
> > x <- tapply(f,f,sum)
> > colnames(x)
> Error in dn[[2]] : subscript out of bounds

What is inappropriate about this?  x is a 1D array, so it does not have
column names (or columns).  Indeed, the help page says

        x: a matrix-like R object, with at least two dimensions for
           'colnames'.

The exact same message appears in 1.6.2, more than three years old (and 
the earliest version I still have running). If earlier versions did not 
have an error message, that was probably a bug.

-- 
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-devel mailing list