getNeighbors: Compute valid nearest neighbors of each valid point on a grid

Description Usage Arguments Value Examples

View source: R/similarity.R

Description

Compute valid nearest neighbors of each valid point on a grid

Usage

1
getNeighbors(mat, mask_fun = function(x) !is.na(x), verbose)

Arguments

mat

Matrix of gridpoints

mask_fun

Function that identifies valid observations For sparseMatrix where 0 denotes NA, use mask_fun = function(x) as.logical(x != 0)

Value

List with IDs of valid points (old and new) and list (ngb) of their neighbors

Examples

1
2
3
4
5
mat = matrix(runif(6), 2, 3)
mat[2,2] = NA
getNeighbors(mat, verbose=F)
mat[2,2] = 0
getNeighbors(enforceM(mat), function(x) as.logical(x != 0), verbose=F)

rtlemos/scurvy documentation built on Dec. 4, 2019, 6:06 a.m.