On Wed, 4 Aug 2010, Guillaume Blanchet wrote:
Thanks Nikhil !!
That is solving my problem !!
Maybe n.comp.nb() in spdep? This returns the number of clusters and
cluster IDs for the observations, in your case:
n.comp.nb(nbobj.new)
$nc
[1] 2
$comp.id
[1] 1 1 2 2 1 1 2 2
Hope this helps,
Roger
Have a good day !
Guillaume Blanchet
Le 10-08-03 21:34, Nikhil Kaza a écrit :
This may be a overkill. but no.clusters in igraph package might work.
require(igraph)
nbobj <- cell2nb(4,2,"rook")
nb.mat <- nb2mat(nbobj)
no.clusters(graph.adjacency(nb.mat))
Nikhil Kaza
Asst. Professor,
City and Regional Planning
University of North Carolina
nikhil.l...@gmail.com
On Aug 3, 2010, at 4:57 PM, Guillaume Blanchet wrote:
Hi !
I am currently working on a wombling (boundary detection) function and I
have come across a nag. Hopefully you will be able to give me a hand on
this.
Following is a small example to explain what I want to do using the spdep
package.
xy<-expand.grid(1:4,1:2)
nbobj<-cell2nb(4,2,"rook")
links<-listw2sn(nb2listw(nbobj))
links.new<-links[-c(4,6,15,17),]
nbobj.new<-sn2listw(links.new)$neighbours
plot(nbobj.new,xy)
"nbobj.new" has two separate groups of points links between each other. Is
there a way to automatically counts the number of independent (non-linked)
groups of sites ?
Thanks in advance !
Guillaume Blanchet
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo