Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.OSF.4.58.0511280425210.387400@wotan.mdacc.tmc.edu>
Date: 2005-11-28T10:35:59Z
From: Paul Roebuck
Subject: Matrix rotation
In-Reply-To: <a670d84c003d14886b4976242ceb7541@cpom.ucl.ac.uk>

On Thu, 24 Nov 2005, Benjamin Lloyd-Hughes wrote:

> Ok I warned you that I'd been drinking! What I really meant was
> something to go from:
>
>       [,1] [,2]
> [1,]    1    2
> [2,]    4    3
>
> to
>
>       [,1] [,2]
> [1,]    4    1
> [2,]    3    2
>
> to
>
>       [,1] [,2]
> [1,]    3    4
> [2,]    2    1
>
> to
>
>       [,1] [,2]
> [1,]    2    3
> [2,]    1    4
>


Another possible solution...

> library(matlab)
> x <- matrix(c(1,2,4,3), nrow=2, byrow=TRUE)
> x
     [,1] [,2]
[1,]    1    2
[2,]    4    3
> matlab::rot90(x, 3)
     [,1] [,2]
[1,]    4    1
[2,]    3    2
> matlab::rot90(x, 2)
     [,1] [,2]
[1,]    3    4
[2,]    2    1
> matlab::rot90(x, 1)
     [,1] [,2]
[1,]    2    3
[2,]    1    4

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)