Given matrix mtx.dense
and positive integer k
it extracts cross pattern cells:
i - k, j
i, j - k
i - (k-1), j
i, j - (k-1)
.
.
.
i - 1, j
i, j - 1
i + 1, j
i, j + 1
.
.
.
i + (k - 1), j
i, j + (k - 1)
i + k, j
i, j + k
i, j
or donut shape. The above cells are columns in resulting data frame, so it has in total 2 + 4 * k + 1 columns: first two are cell coordinates in initial matrix, i.e.: i and j, remaining columns are the above values (in the order specified above). Selection of cross size k
enforces that cells belonging to rows, columns or diagonals (starting at main diagonal) with indices 1 to k
or n-k+1
to n
can't be assigned any value.
1 2 3 4 5 6 7 8 | neighborhood(
mtx.dense,
k = 1,
max.d = 0.15,
m = 1,
which.ngb = c("cross", "donut")[1],
include.ij = FALSE
)
|
mtx.dense |
numeric symmetric matrix |
k |
numeric radius size |
max.d |
numeric fraction of domains to be taken, i.e.: if |
m |
numeric how many diagonals (starting at main diagonal) to discard, by definition of cross this must be fixed to m > k to have effect as m will be finally be selected as: |
which.ngb |
character indicating the shape of neighborhood to extract, either "cross" or "donut" |
include.ij |
logical whether to include the value of cell for which neighborhood is extracted |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.