View source: R/gridadjacency.R
gridadjacencymatrix | R Documentation |
Given the dimensions of a rectangular grid of points, this command creates the adjacency matrix for the corresponding neighbourhood graph, whose vertices are the grid points, and whose edges are the joins between neighbouring grid points.
gridadjacencymatrix(dims, across = TRUE, down = TRUE, diagonal=TRUE)
dims |
Grid dimensions. An integer, or a vector of two integers.
First entry specifies the number of points in the |
across |
Logical value equal to |
down |
Logical value equal to |
diagonal |
Logical value equal to |
If N = prod(dims)
is the total number of grid points,
then the result is an N * N
sparse matrix with logical entries
equal to TRUE
if the corresponding grid points are joined.
A sparse matrix.
Adrian Baddeley.
gridadjacencymatrix(c(2,3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.