[Rd] c.factor

Barry Rowlingson B.Rowlingson at lancaster.ac.uk
Wed Nov 15 18:45:31 CET 2006


> 
> It does not remove names in Splus either, just all
> other attributes.  I see c() used in several Splus
> functions as a way to convert a matrix into a vector
> (by removing the .Dims and .Dimnames attributes).
> 

  I dont see the logic in certain attribute names (?attr lists 'class', 
'comment', 'dim', 'dimnames', 'names', 'row.names' and 'tsp') being 
'special'. Why are matrices  vectors with some 'magic' attribute 'dim', 
and possibly some non-magic attributes like 'umbongo' and 'fnord'? I'd 
have the dim (and other essential properties of data structures) more 
tightly bound to the data. attr(M,'dim')=NULL seems a very odd way of 
turning a matrix into a vector.

  If I was the R bdfl[1] I'd deprecate using 'attr' to access these 
aspects of data objects and insist on using "dim(M)" or 
"row.names(M)=foo". Then I can use 'attr' for any old annotations, for 
example in my light bulb brightness study I could do:

  sample1 = c(4.2,4.5,4.8,4.1)
  attr(sample1,'dim') = TRUE

  sample2 = c(5.6,5.8,6.7,6.5,9.3)
  attr(sample2,'dim') = FALSE

Barry

[1] http://en.wikipedia.org/wiki/Benevolent_Dictator_for_Life



More information about the R-devel mailing list