I belive that

apply(t(mat),2,rev)
     [,1] [,2] [,3]
[1,]    1    6    3
[2,]    2    2    5
[3,]    1    3    4

will do what you want.  I'll leave it up to you to decide
whether it's straightforward.
                                        - Phil Spector
                                         Statistical Computing Facility
                                         Department of Statistics
                                         UC Berkeley
                                         spec...@stat.berkeley.edu


On Thu, 18 Mar 2010, dc896148 wrote:


useR's,
I want to be able to rotate a matrix 90 degrees, clockwise.  For example,
mat
    [,1] [,2] [,3]
[,1]   1    2     1
[,2]   3    2     6
[,3]   4    5     3

I want to rotate it, so that it looks like this...
    [,1] [,2] [,3]
[,1]   4    3     1
[,2]   5    2     2
[,3]   3    6     1

Does anyone know a quick and straightforward way to do this?

Thanks in advance.
--
View this message in context: 
http://n4.nabble.com/can-I-rotate-a-matrix-tp1598469p1598469.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to