[R] can I rotate a matrix

Henrique Dallazuanna wwwhsd at gmail.com
Thu Mar 18 20:48:53 CET 2010


Try this:

t(mat[3:1,])

On Thu, Mar 18, 2010 at 4:10 PM, dc896148 <cyr.derek at gmail.com> 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 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list