[R] the real dimnames

Peter Dalgaard pdalgd at gmail.com
Tue Jul 27 08:26:53 CEST 2010


Michael Lachmann wrote:
> Hi,
> 
> R seems to have a feature that isn't used much, which I don't really  
> now how to call. But, the dimnames function, can in addition to giving  
> names to rows/columns/dim 3 rows/dim 4 rows... can also give labels to  
> the dimensions themselves.

Actually, this is used extensively in tabulations, and is the main
reason for the existence of 1D-arrays (there's no way to name the names
on an ordinary vector).

> str(with(airquality,table(Month)))
 'table' int [1:5(1d)] 31 30 31 31 30
 - attr(*, "dimnames")=List of 1
  ..$ Month: chr [1:5] "5" "6" "7" "8" ...

> with(airquality,table(Month))
Month
 5  6  7  8  9
31 30 31 31 30


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list