20 Jun 2012 18:40
plot nearest neighbor links
Juliane Struve <juliane_struve <at> yahoo.co.uk>
2012-06-20 16:40:31 GMT
2012-06-20 16:40:31 GMT
Dear list, I would like to plot the links that dnearneigh() identifies. Space <- matrix(data = 1, nrow = 10, ncol = 10) Space[1,] <- NA Space[nrow(Space),] <- NA Space[,1] <- NA Space[,ncol(Space)] <- NA WaterRow <- row(Space) WaterCol <- col(Space) WaterXY <- cbind(X=WaterRow[Space==1], Y=WaterCol[Space==1]) library(spdep) WaterXY <- na.omit(WaterXY) WaterNB <- dnearneigh(WaterXY, 0, 1) res <- listw2sn(nb2listw(WaterNB))[,1:2] as.matrix(res) I have found an older post on a related topic that shows an example of what I would like to do: example(read.gal) # to get an nb object us48.q us48.q[1:2] res <- listw2sn(nb2listw(us48.q))[,1:2] res[1:9,] str(res) I have managed to retrieve the links using as.matrix(res), but I can't get the plot of nodes and links to appear.(Continue reading)
RSS Feed