neighbour_idx: Get all indices in neighbourhood

Description Usage Arguments Examples

View source: R/index.R

Description

Get all indices in neighbourhood

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

matricks documentation built on March 26, 2020, 6:22 p.m.