Skip to content
Prev 302734 / 398503 Next

dimnames in array

On Aug 8, 2012, at 3:19 AM, aleksandr russell wrote:

            
I didn't run that code since your difficulties did not seem to have  
anything to do with the values inside the array but only with the  
dimension labeling.
What is 'data2'?
Ditto... what is 'data6'?
For which object?
The data11 object had three dimenstions.
Here's one way to label a 41 x 2 x 2 array:

 > dimnames(data11)<- c(list(X=paste0("X",1:41)), list(Y=paste0("Y", 
1:2)), list(Z=paste0("Z",1:2)) )
 > attributes(data11)
$dim
[1] 41  2  2

$dimnames
$dimnames$X
  [1] "X1"  "X2"  "X3"  "X4"  "X5"  "X6"  "X7"  "X8"  "X9"  "X10"  
"X11" "X12" "X13" "X14" "X15" "X16" "X17" "X18" "X19"
[20] "X20" "X21" "X22" "X23" "X24" "X25" "X26" "X27" "X28" "X29" "X30"  
"X31" "X32" "X33" "X34" "X35" "X36" "X37" "X38"
[39] "X39" "X40" "X41"

$dimnames$Y
[1] "Y1" "Y2"

$dimnames$Z
[1] "Z1" "Z2"
It is a one element list whose single element is a 2 element vector.