count_neighbours | R Documentation |
Count neighbours for each element in a binary matrix
count_neighbours(x)
x |
The matrix to count the neighbours in. |
A matrix of the same size as x
giving the number of elements with non-zero
values in neighbouring cells of the matrix.
x <- matrix(
c(1L, 1L, 0L,
1L, 1L, 0L,
0L, 1L, 1L),
nrow = 3,
ncol = 3,
byrow = TRUE
)
beadplexr:::count_neighbours(x)
x <- matrix(
c(TRUE, TRUE, FALSE,
TRUE, TRUE, FALSE,
FALSE, TRUE, TRUE),
nrow = 3,
ncol = 3,
byrow = TRUE
)
beadplexr:::count_neighbours(x)
x <- matrix(
c(1, 1, 0, 0,
1, 0, 0, 0,
0, 1, 1 ,1,
0, 1, 1, 1),
nrow = 4,
ncol = 4,
byrow = TRUE
)
beadplexr:::count_neighbours(x)
## Not run:
x <- matrix(
c("1", "1", "0",
"1", "1", "0",
"0", "1", "1"),
nrow = 3,
ncol = 3,
byrow = TRUE
)
#beadplexr:::count_neighbours(x)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.