[R-sig-Geo] Complete neighbours
German Sanchez Hernandez
german.sanchez at ais-int.com
Fri Sep 3 15:05:08 CEST 2010
Dear list,
I would like to complete my neighbour list in order to increase the number of neighbours of regions with less neighbours (links) than a certain number. The idea is to complete these links using knearneigh function.
My try:
nb <- poly2nb(map)
# Compute distribution of linkage:
distr <- as.data.frame(table(card(nb)))
# Try to identify the "isolated" regions (equal or less than, for example, 3 neighbours
minim <- 3 # It's a computed number
isolated <- subset(nb, subset=card(nb) <= minim)
# Get the "isolated" region IDs
regions <- attr(unclass(isolated), 'region.id')
# Modify nb using knearneigh ¿?
# Alternative 2:
nbmat <- nb2mat(nb)
# Modify nbmat ¿?, mat2listw, listw2nb
# Alternative 3:
listw <- nb2listw(nb)
# Modify listw ¿?, listw2nb
The question is:
How to modify nb (or nbmat or listw) to increase the number of links of the "isolated" regions?
Any idea?
Thank you!
Germán Sánchez
More information about the R-sig-Geo
mailing list