Skip to content
Prev 3332 / 29559 Next

How to check a large neighbourhood matrix?

Oscar:

If you produced the nb list in R, you can always summarize the nb list 
to see whether there are units that don't have neighbors.

For instance:
#loading spdep
library(spdep)

#you have read a shapefile of postal code areas:

post<-read.shape("../yourshapefile.shp")

#since it is a polygon shapefile, a Map2poly and poly2nb function shall 
do the trick (Roger will have better ideas than my naive ones)

post.nb<-poly2nb(Map2poly(post))

#then you summarize the nb list:

summary(post.nb)

The summary command will give you the characteristics of the neighbor 
list object, including Number of regions, Number of nonzero links, 
Percentage nonzero weights, Average number of links, regions that have 
no links (which shall give you the idea whether or not some postal code 
areas are connected) and the most and least connected regions

Hope this helps.

Regards,
Dr. Danlin Yu
Oscar Breugelmans wrote: