neighbour_idx {matricks} | R Documentation |
Get all indices in neighbourhood
Description
Get all indices in neighbourhood
Usage
neighbour_idx(mat, idx, mask = NULL, diagonal = TRUE,
include.idx = FALSE)
Arguments
mat |
matrix or data.frame |
idx |
two-element vector |
mask |
logical matrix; optional |
diagonal |
include diagonal neighbours |
include.idx |
include current index |
Examples
mat <- matrix(0, 3, 3)
neighbour_idx(mat, c(1, 2))
neighbour_idx(mat, c(1, 2), diagonal = FALSE)
neighbour_idx(mat, c(1, 2), diagonal = FALSE, include.idx = TRUE)
# With mask
mat <- matrix(0, 3, 4)
mask <- m(FALSE, FALSE, TRUE, TRUE |
FALSE, FALSE, FALSE, FALSE |
TRUE, TRUE, FALSE, TRUE)
neighbour_idx(mat, c(1, 2), mask = mask)
[Package matricks version 0.8.2 Index]