[R] Transpose array

Greg Snow Greg.Snow at imail.org
Tue Feb 24 19:06:48 CET 2009


Try aperm(x, c(2,1,3))

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of MarcioRibeiro
> Sent: Tuesday, February 24, 2009 9:50 AM
> To: r-help at r-project.org
> Subject: [R] Transpose array
> 
> 
> Hi Listers,
> Is there a way that I can transpose an array...
> Suppose I have the following array...
> 
> x<-array(c(1,2,3,4),dim=c(1,2,2))
> , , 1
>      [,1] [,2]
> [1,]    1    2
> , , 2
>      [,1] [,2]
> [1,]    3    4
> 
> And I would like to get the following result...
> , , 1
>      [,1]
> [1,]    1
> [,2]    2
> , , 2
>      [,1] [,2]
> [1,]    3
> [,2]    4
> 
> Thanks in advance,
> Marcio
> --
> View this message in context: http://www.nabble.com/Transpose-array-
> tp22184286p22184286.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list