[R] Rotate array by 90°

Karim Mezhoud kmezhoud at gmail.com
Thu Feb 5 22:17:43 CET 2015


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]]



More information about the R-help mailing list