[R-sig-Geo] Neighborhood matrix from poly2nb (spdep package)
Roger Bivand
Roger.Bivand at nhh.no
Fri Nov 4 14:42:04 CET 2016
On Fri, 4 Nov 2016, Maaz Gardezi wrote:
> Hi,
>
> I'm trying to extract the 'neighborhood matrix' from the poly2nb function.
No, it returns (see ?poly2nb):
A neighbours list with class ‘nb’. See ‘card’ for details of “nb” objects.
Look at ?nb2mat, but then you'll also be obliged to decide on the style=
argument, or use ?nb2list first.
Making a "neigbourhood matrix" involves several steps, each of which
should be taken consciously. Also maybe see vignette("nb") and
vignette("nb_igraph").
Roger
>
> I can see the neighbors for each polygon, e.g. 1 has neighbors 2, 3, 5, 6.
>
> I try to convert this matrix into a data frame but get the error "cannot
> coerce class ""nb"" to a data.frame". Is there any way of doing this in the
> spdep package?
>
> Other possible ways?
>
> Regards,
>
> Maaz
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
More information about the R-sig-Geo
mailing list