rotate90: Matrix or Array Rotation by 90 Degrees

View source: R/utils.R

rotate90R Documentation

Matrix or Array Rotation by 90 Degrees

Description

Matrix or Array Rotation by 90 Degrees

Usage

rotate90(img, direction = "positive")

Arguments

img

an array or a matrix

direction

The direction of rotation by 90 degrees. The value can be "positive" (default) or "negative". Aliases are "counterclockwise" and "clockwise", respectively.

Details

The function takes an array or matrix as input object (img) and returns the object rotated by 90 degrees. Per default, the rotation is done in the mathematically positive direction (i.e., counterclockwise). Clockwise rotation (i.e., mathematically negative) can be specified by passing the value "negative" to the direction argument.

Value

an array or a matrix (rotated by 90 degrees)

Examples

# sample matrix
img <- matrix(1:6, ncol = 2)
img

rotate90(img) # counterclockwise
rotate90(img, direction = "negative") # clockwise

stm/rquantae documentation built on Feb. 29, 2024, 4:08 p.m.