From B.Rowlingson at lancaster.ac.uk  Wed Nov 15 18:45:31 2006
From: B.Rowlingson at lancaster.ac.uk (Barry Rowlingson)
Date: Wed, 15 Nov 2006 17:45:31 +0000
Subject: [Rd] c.factor
In-Reply-To: <Pine.GSO.4.56.0611150918020.12673@durian.statsci.com>
References: <946928E281E8FD4B91D5B2CC3C91967D6AA9A0@lnex01.CONCORDIAFUNDS.COM>	<1163526685.4492.20.camel@localhost.localdomain>	<1163527030.4492.23.camel@localhost.localdomain>	<Pine.LNX.4.64.0611141809050.25751@gannet.stats.ox.ac.uk>	<Pine.GSO.4.56.0611141218410.17778@durian.statsci.com>	<Pine.LNX.4.64.0611150926070.19618@auk.stats>
	<Pine.GSO.4.56.0611150918020.12673@durian.statsci.com>
Message-ID: <455B523B.4050800@lancaster.ac.uk>


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



[Rd] c.factor
Barry Rowlingson