From enrique.bengoechea at credit-suisse.com  Wed Jul  8 10:15:04 2009
From: enrique.bengoechea at credit-suisse.com (=?iso-8859-1?Q?Bengoechea_Bartolom=E9_Enrique_=28SIES_73=29?=)
Date: Wed, 8 Jul 2009 10:15:04 +0200
Subject: [Rd] Suggestion: Dimension-sensitive attributes
Message-ID: <19811401A1D8174CB3EAD7F6072E9B50023F38A7@chsa1025.share.beluni.net>

Hi,

I agree with Henrik that his suggestion to have "dimension vector attributes" working like dimnames (see below) would be an extremely useful infrastructure adittion to R.

If this is not considered for R-core, I am happy to try to implement this in a package, as a new class. And possibly do the same thing for data frames. Should you have any comments, ideas or suggestions about it, please share!

Best,

Enrique

-----------------------------------------------------------------------------
Subject: 
From: Henrik Bengtsson <hb_at_stat.berkeley.edu 
Date: Sun, 07 Jun 2009 14:42:08 -0700

Hi, 

maybe this has been suggested before, but would it be possible, without not breaking too much existing code, to add other "dimension vector attributes" in addition to 'dimnames'? These attributes would then be subsetted just like dimnames. 

Something like this: 

> x <- array(1:30, dim=c(2,3,5)) 
> dimnames(x) <- list(c("a", "b"), c("a1", "a2", "a3"), NULL); 
> dimattr(x, "misc") <- list(1:2, list(x=1:5, y=letters[1:8], z=NA), letters[1:5]); 


> y <- x[,1:2,2:3] 
> str(dimnames(y)) 

List of 3 

 $ : chr [1:2] "a" "b"
 $ : chr [1:2] "a1" "a2"
 $ : NULL


> str(dimattr(x, "misc")) 

List of 3 
 $ : int [1:2] 1 2 
 $ :List of 2 
  ..$ x: int [1:5] 1 2 3 4 5 
  ..$ y: chr [1:8] "a" "b" "c" "d" ... 
 $ : chr [1:2] "b" "c" 

 I can imagine this needs to be added in several places and functions such as is.vector() needs to be updated etc. It is not a quick migration, but is it something worth considering for the future? 

/Henrik 



[Rd] Suggestion: Dimension-sensitive attributes
=?iso-8859-1?Q?Bengoechea_Bartolom=E9_Enrique_=28SIES_73=29?=