mat_apply: Apply Function with Optimised Functions

Description Usage Arguments Examples

View source: R/nhapply_functions.R

Description

Applies a function to each column of an open matrix, just like apply, with most common functions optimised. Output is a vector with the length equal to the number of columns of the input matrix.

Usage

1
mat_apply(mat_open, FUN, weights = 1)

Arguments

mat_open

is the input matrix. Every column should represent a pixel-neighbourhood and every row one element of that neighbourhood.

FUN

is a function, that is applied on the neighbourhood of each point of a matrix. Optimised functions are: "mean", "sum", "max", "min", "maxCount", "maxCountValue" (which value occurs most often). It is possible to add a customised function like function(x) ... which must return a single value.

weights

is a vector of weights that is used when summing up a neighbourhood. Vector length must be the same as points in neighbourhood.

Examples

1
2
mat_inp <- matrix(sample(1:5, 10^6, rep = TRUE), nrow=10)
invisible(mat_apply(mat_inp, FUN = "maxcountvalue"))

Tobiaspk/RPackage_nhapply documentation built on Feb. 19, 2021, 12:13 a.m.