Hi: Before you do all of that, might one inquire about which goal you are trying to achieve? Perhaps a 27-dimensional array may not be the wisest choice of data structure for your goal.
Dennis On Thu, Jan 21, 2010 at 3:06 PM, LCOG1 <[email protected]> wrote: > > Hello all, > I have data from a csv that i need to coerce into a multi dimensional > array. As you can see from my sample code i have yet to master building > efficient code. I can sort of do what i want but its very cumbersome code > and i know there is a better way to do it, i am just not expereinced > enought > yet. So for the following: > > #Create Data > h1i1a1<-sample(1:20, 5, replace=TRUE) > h1i1a2<-sample(1:20, 5, replace=TRUE) > h1i1a3<-sample(1:20, 5, replace=TRUE) > h1i2a1<-sample(1:20, 5, replace=TRUE) > h1i2a2<-sample(1:20, 5, replace=TRUE) > h1i2a3<-sample(1:20, 5, replace=TRUE) > h1i3a1<-sample(1:20, 5, replace=TRUE) > h1i3a2<-sample(1:20, 5, replace=TRUE) > h1i3a3<-sample(1:20, 5, replace=TRUE) > h1i4a1<-sample(1:20, 5, replace=TRUE) > h1i4a2<-sample(1:20, 5, replace=TRUE) > h1i4a3<-sample(1:20, 5, replace=TRUE) > h2i1a1<-sample(1:20, 5, replace=TRUE) > h2i1a2<-sample(1:20, 5, replace=TRUE) > h2i1a3<-sample(1:20, 5, replace=TRUE) > h2i2a1<-sample(1:20, 5, replace=TRUE) > h2i2a2<-sample(1:20, 5, replace=TRUE) > h2i2a3<-sample(1:20, 5, replace=TRUE) > h2i3a1<-sample(1:20, 5, replace=TRUE) > h2i3a2<-sample(1:20, 5, replace=TRUE) > h2i3a3<-sample(1:20, 5, replace=TRUE) > h2i4a1<-sample(1:20, 5, replace=TRUE) > h2i4a2<-sample(1:20, 5, replace=TRUE) > h2i4a3<-sample(1:20, 5, replace=TRUE) > h3i1a1<-sample(1:20, 5, replace=TRUE) > h3i1a2<-sample(1:20, 5, replace=TRUE) > h3i1a3<-sample(1:20, 5, replace=TRUE) > h3i2a1<-sample(1:20, 5, replace=TRUE) > h3i2a2<-sample(1:20, 5, replace=TRUE) > h3i2a3<-sample(1:20, 5, replace=TRUE) > h3i3a1<-sample(1:20, 5, replace=TRUE) > h3i3a2<-sample(1:20, 5, replace=TRUE) > h3i3a3<-sample(1:20, 5, replace=TRUE) > #Put into data frame > > hia<-data.frame(h1i1a1,h1i1a2,h1i1a3,h1i2a1,h1i2a2,h1i2a3,h1i3a1,h1i3a2,h1i3a3,h1i4a1,h1i4a2,h1i4a3,h2i1a1,h2i1a2,h2i1a3,h2i2a1,h2i2a2,h2i2a3,h2i3a1,h2i3a2,h2i3a3,h2i4a1,h2i4a2,h2i4a3,h3i1a1,h3i1a2,h3i1a3,h3i2a1,h3i2a2,h3i2a3,h3i3a1,h3i3a2,h3i3a3) > > i would like to produce a multidimensional array that looks something like > > h1 h2 h3 > i1 X X X > i2 X X X > i3 X X X > > a = 1 , TAZ = 1:5 ->for all 5 TAZ values or each row > > h1 h2 h3 > i1 X X X > i2 X X X > i3 X X X > > a = 2 , TAZ = i in 1:5 > > h1 h2 h3 > i1 X X X > i2 X X X > i3 X X X > > a = 3 , TAZ = i in 1:5 > > Basically a matrix for all possible combination, so 27 matrices > altogether. > But i guess its more like an array of arrays? Again i am not being lazy, i > have been working on this all day but my code, like my sample stuff is very > inefficient and ultimately not working well so im not bothering to post it. > I know this will be complicated so thank you in advance, seeing the end > code > will teach me a great deal. Thanks > > Cheers, > JR > -- > View this message in context: > http://n4.nabble.com/Create-a-multi-dimensional-array-from-a-data-frame-tp1068487p1068487.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

