compressMatrix: Resize a Matrix By Combining Adjacent Elements

Description Usage Arguments Value Author(s)

View source: R/compressMatrix.R

Description

compressMatrix() resizes a matrix by averaging groups of adjacent rows/columns (typically averaging or summing).

Usage

1
compressMatrix(X, howmuch = 4, FUN = mean, na.rm = T, ...)

Arguments

X

A matrix or object that can be coerced to such (array, data.frame), typically numeric, though other types are possible depending on the FUN argument.

howmuch

One or two element integer vector specifying compression factor in each dimension. If length(howmuch)==1, both dimensions will be reduced by the same factor.

FUN

Function to apply for combining values.

na.rm

Logical; if TRUE, remove missing values from X prior to calling FUN

...

Additional arguments passed to FUN

Value

Returns a matrix with dimensions dim(X) / howmuch, where each element is average of howmuch[1] neighboring rows and howmuch[2] neighboring columns. If the original dimensions of X are not evenly divisible by howmuch, additional rows and/or columns of missing values will be appended.

Author(s)

M.W.Rowe, mwr.stats@gmail.com


mwrowe/microRutils documentation built on June 12, 2021, 2:41 p.m.