[R] Rotate array by 90°
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Thu Feb 5 23:00:43 CET 2015
?aperm
aperm(A, c(2,1,3) )[,3:1,]
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
On February 5, 2015 1:17:43 PM PST, Karim Mezhoud <kmezhoud at gmail.com> wrote:
>Dear aal,
>
>Is there a way to rotate array or a cube of matrices by Y axis?
>
>
>MatLab example:
>
>A = cat(3,{'a' 'b' 'c';'d' 'e' 'f';'g' 'h' 'i'},{'j' 'k' 'l';'m' 'n'
>'o';'p' 'q' 'r'})
>
>A(:,:,1) =
>
> 'a' 'b' 'c'
> 'd' 'e' 'f'
> 'g' 'h' 'i'
>
>
>A(:,:,2) =
>
> 'j' 'k' 'l'
> 'm' 'n' 'o'
> 'p' 'q' 'r'
>
>Rotate the cell array by 270 degrees.
>
>B = rot90(A,3)
>
>B(:,:,1) =
>
> 'g' 'd' 'a'
> 'h' 'e' 'b'
> 'i' 'f' 'c'
>
>
>B(:,:,2) =
>
> 'p' 'm' 'j'
> 'q' 'n' 'k'
> 'r' 'o' 'l'
>
>
>karim
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.
More information about the R-help
mailing list