Re: [Rd] c.factor

From: Barry Rowlingson <B.Rowlingson_at_lancaster.ac.uk>
Date: Wed 15 Nov 2006 - 17:45:31 GMT

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



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Nov 16 11:02:33 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 16 Nov 2006 - 00:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.