rotMatrix: Rotate values in a matrix

Description Usage Arguments Value See Also Examples

View source: R/rotMatrix.r

Description

This function rotates the values in a matrix by a user-specified number of degrees. In almost all cases some values will fall outside the matrix so they will be discarded. Cells that have no rotated values will become NA. Only scquare matrices can be accomodated. In some cases a rotation will cause cells to have no assigned value because no original values fall within them. In these instances the mean value of surrounding cells is assigned to the cells with missing values. If the angle of rotation is too small then no rotation will occur.

Usage

1
rotMatrix(x, rot)

Arguments

x

Object of class matrix.

rot

Numeric. Number of degrees to rotate matrix. Values represent difference in degrees between "north" (up) and the clockwise direction.

Value

A matrix.

See Also

[base::t()]

Examples

1
2
3
4
5
6
7
x <- matrix(1:100, nrow=10)
x
rotMatrix(x, 90) # 90 degrees to the right
rotMatrix(x, 180) # 180 degrees to the right
rotMatrix(x, 45) # 45 degrees to the right
rotMatrix(x, 7) # slight rotation
rotMatrix(x, 5) # no rotatation because angle is too small

adamlilith/omnibus documentation built on Nov. 21, 2018, 11:01 a.m.