Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rot90

Matrix Rotation


Description

Rotate matrices for 90, 180, or 270 degrees..

Usage

rot90(a, k = 1)

Arguments

a

numeric or complex matrix

k

scalar integer number of times the matrix will be rotated for 90 degrees; may be negative.

Details

Rotates a numeric or complex matrix for 90 (k = 1), 180 (k = 2) or 270 (k = 3 or k = -1) degrees.

Value of k is taken mod 4.

Value

the original matrix rotated

Examples

a <- matrix(1:12, nrow=3, ncol=4, byrow=TRUE)
rot90(a)
rot90(a, 2)
rot90(a, -1)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.