resizeMatrix: resize a numeric matrix to given dimensions

View source: R/resizeMatrix.R

resizeMatrixR Documentation

resize a numeric matrix to given dimensions

Description

resize a numeric matrix to given dimensions

Usage

resizeMatrix(mat, ndim = dim(mat), method = c("mean", "max", "min"))

Arguments

mat

A numeric matrix

ndim

The desired output dimensions

method

Whether to use normal interpolation ('method="mean"', the default), or the max or min of the overlapping grid cells.

Details

For most cased this is based on Vyha's implementation (taken from https://stackoverflow.com/a/23429527 ), but adding the possibility to replace normal interpolation with the max/min of the overlapping grid cells. This works well when the desired dimensions are at least half of the input ones. When the desired dimensions are smaller, a different binning method is used, first applied on columns and then on rows.

Value

A numeric matrix of dimensions 'ndim'


ETHZ-INS/epiwraps documentation built on Oct. 27, 2024, 8:02 p.m.