Hi, Try this: b1<-aperm(array(a,dim=c(5,2,2)),perm=c(2,1,3)) > b1 , , 1
[,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 6 7 8 9 10 , , 2 [,1] [,2] [,3] [,4] [,5] [1,] 11 12 13 14 15 [2,] 16 17 18 19 20 A.K. ----- Original Message ----- From: HJ YAN <yhj...@googlemail.com> To: r-help@r-project.org Cc: Sent: Monday, July 9, 2012 7:25 PM Subject: [R] Read vector as multi-dimensional data in R by row Dear R users Say I wanted to read a vector into R as multi-dimensional array by row, e.g. a<-c(1:20) > b<-array(a,dim=c(2,5,2)) > b , , 1 [,1] [,2] [,3] [,4] [,5] [1,] 1 3 5 7 9 [2,] 2 4 6 8 10 , , 2 [,1] [,2] [,3] [,4] [,5] [1,] 11 13 15 17 19 [2,] 12 14 16 18 20 But actually I wanted... [,1] [,2] [,3] [,4] [,5] [1,] 1 2 3 4 5 [2,] 6 7 8 9 10 , , 2 [,1] [,2] [,3] [,4] [,5] [1,] 11 12 13 14 15 [2,] 16 17 18 19 20 I checked '?array' but there is not an argument or something like 'byrow=T' as the one in 'matrix'. Could anyone help please? Many thanks in advance! HJ [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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. ______________________________________________ R-help@r-project.org 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.