Skip to content

help for cell2nb and queencell in spdep package

2 messages · ecoinfo, Roger Bivand

#
On Wed, 3 Aug 2005, ecoinfo wrote:

            
neigh is a list of integer vectors, so you can use standard indexing:
[1] 2

using double square brackets for accessing the list components, and single 
for the vector elements. I think this is what you are asking for, if not, 
please clarify. To find out which (row, column) address this corresponds 
to, look it up in the "region.id" attribute:
[1] "2:1"
"rowcol: matrix with two columns of row, column indices"

The queencell function is used internally, but takes a single row matrix 
of (row, column) indices, and returns a matrix of (row, column) indices 
for the contiguous neighbours of that cell:
row col
[1,]   2   8
[2,]   1   8
[3,]   8   8
[4,]   2   1
[5,]   8   1
[6,]   2   2
[7,]   1   2
[8,]   8   2
attr(,"coords")
[1] 1 1

for your case on a torus.

Hope this helps,

Roger