[R] can I rotate a matrix

Rolf Turner r.turner at auckland.ac.nz
Thu Mar 18 20:51:42 CET 2010


On 19/03/2010, at 8:10 AM, 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?

Does

	t(mat[nrow(mat):1,])

float your boat?

	cheers,

		Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list