Dear Dr. Vokey,

Here is one approach, although may not be the more efficient:

x <- matrix(1:8, ncol = 4)
x
#     [,1] [,2] [,3] [,4]
#[1,]    1    3    5    7
#[2,]    2    4    6    8

t(x[, ncol(x):1])
#     [,1] [,2]
#[1,]    7    8
#[2,]    5    6
#[3,]    3    4
#[4,]    1    2

leftTranspose <- function(x)  t(x[, ncol(x):1])
leftTranspose(x)

HTH.
Jorge.-


On Tue, Oct 22, 2013 at 12:52 PM, Vokey, John <> wrote:

> useRs,
>   I frequently require the following transform of a matrix that I call a
> leftTranspose:
>
>   -- transposes x such that the last items of each row become
>   -- the first items in each column.  E.g.,
>   --      a b c d
>   --      e f g h
>   -- becomes:
>   -- d h
>   -- c g
>   -- b f
>   -- a e
>
> because it is a leftward rotation.  I have written my own function, but I
> was wondering whether I was reinventing the wheel here.  Does such a
> transpose already exist in R (or matlab/octave/FreeMat, for that matter)?
>
>
> --
> Please avoid sending me Word or PowerPoint attachments.
> See <http://www.gnu.org/philosophy/no-word-attachments.html>
>
> -Dr. John R. Vokey
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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