On Wed, 15 Nov 2006, Barry Rowlingson wrote: > > > > > 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".
I have a less than vague feeling that you as bdfl are describing new-style classes: library(Matrix) x <- Matrix(1:6, nrow=2, ncol=3) getSlots(class(x)) slot(x, "Dim") slot(x, "Dim") <- NULL but perhaps unfortunately: slot(x, "Dim") <- as.integer(c(0,0,0)) works! Maybe not quite what was intended? > 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 > -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel