[R] How to "flatten" a multidimensional array into a dataframe?

Emmanuel Levy emmanuel.levy at gmail.com
Thu Apr 19 22:46:56 CEST 2012


Hi,

I have a three dimensional array, e.g.,

my.array = array(0, dim=c(2,3,4), dimnames=list( d1=c("A1","A2"),
d2=c("B1","B2","B3"), d3=c("C1","C2","C3","C4")) )

what I would like to get is then a dataframe:

d1 d2 d3  value
A1 B1 C1 0
A2 B1 C1 0
.
.
.
A2 B3 C4 0

I'm sure there is one function to do this transformation, I just don't
know which one.

Thanks for your help,

Emmanuel



More information about the R-help mailing list