Re: [R] Extracting the dimnames of an array with variable dimensions

2011-05-16 Thread Pierre Roudier
quot;a"  "A"  "f" >  [9,] "b"  "B"  "f" > [10,] "c"  "B"  "f" > [11,] "d"  "B"  "f" > [12,] "a"  "C"  "f" > [13,] "d"  "C&q

Re: [R] Extracting the dimnames of an array with variable dimensions

2011-05-15 Thread Bill.Venables
t; [6,] "c" "C" "e" [7,] "b" "D" "e" [8,] "a" "A" "f" [9,] "b" "B" "f" [10,] "c" "B" "f" [11,] "d" "B" "f&qu

Re: [R] Extracting the dimnames of an array with variable dimensions

2011-05-15 Thread Pierre Roudier
Hi Dennis, Thanks for your answer, it works very well - clever way to sort the problem! Cheers, Pierre 2011/5/16 Dennis Murphy : > Hi: > > Does it have to be an array?  If all you're interested in is the > dimnames, how about this? > > library(plyr) > foo <- array(data = rnorm(32), dim = c(4,4,

Re: [R] Extracting the dimnames of an array with variable dimensions

2011-05-15 Thread Dennis Murphy
Hi: Does it have to be an array? If all you're interested in is the dimnames, how about this? library(plyr) foo <- array(data = rnorm(32), dim = c(4,4,2), dimnames=list(letters[1:4], LETTERS[1:4], letters[5:6])) > foo , , e A B C D a -0.2

[R] Extracting the dimnames of an array with variable dimensions

2011-05-15 Thread Pierre Roudier
Hi list, In a function I am writing, I need to extract the dimension names of an array. I know this can be acheived easily using dimnames() but my problem is that I want my function to be robust when the number of dimensions varies. Consider the following case: foo <- array(data = rnorm(32), dim