Description Usage Arguments Value Note See Also Examples
sNeighDirect
is supposed to calculate direct neighbors for each
hexagon/rectangle in a regular 2D grid. It returns a matrix with rows
for the self, and columns for its direct neighbors.
1 | sNeighDirect(sObj)
|
sObj |
an object of class "sTopol" or "sInit" or "sMap" |
dNeigh
: a matrix of nHex x nHex, containing
presence/absence info in terms of direct neighbors, where nHex is the
total number of hexagons/rectanges in the grid
The return matrix has rows for the self, and columns for its direct neighbors. The "1" means the presence of direct neighbors, "0" for the absence. It has rows/columns ordered in the same order as the "coord" matrix of the input object does.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # 1) generate an iid normal random matrix of 100x10
data <- matrix( rnorm(100*10,mean=0,sd=1), nrow=100, ncol=10)
# 2) from this input matrix, determine nHex=5*sqrt(nrow(data))=50,
# but it returns nHex=61, via "sHexGrid(nHex=50)", to make sure a supra-hexagonal grid
sTopol <- sTopology(data=data, lattice="hexa", shape="suprahex")
# 3) initialise the codebook matrix using "uniform" method
sI <- sInitial(data=data, sTopol=sTopol, init="uniform")
# 4) calculate direct neighbors based on different objects
# 4a) based on an object of class "sTopol"
dNeigh <- sNeighDirect(sObj=sTopol)
# 4b) based on an object of class "sMap"
# dNeigh <- sNeighDirect(sObj=sI)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.