Re: [R] Chopping a two column data frame by rows into a three dimensional array.
aperm(array(dat,c(10,10,2)),c(1,3,2)) --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: O
Re: [R] Chopping a two column data frame by rows into a three dimensional array.
HI, May be this: dat <- cbind(x=c(1:100),y=c(100:1)) newarray<-array(do.call(cbind,lapply(split(dat,rep(1:10,each=10)),function(x) cbind(x=x[1:10],y=x[11:20]))),dim=c(10,2,10)) colnames(newarray)<-c("x","y") newarray[,,1] # x y #[1,] 1 100 #[2,] 2 99 #[3,] 3 98 #[4,] 4 97