Re: [R] matrix to gal object

From: Roger Bivand <Roger.Bivand_at_nhh.no>
Date: Sat, 22 Dec 2007 13:11:04 +0000 (UTC)

bernardo lagos alvarez <blacertain <at> gmail.com> writes:

>
> useR's
>
> I need transform the matrix
>
> wdat
> [,1] [,2] [,3] [,4] [,5] [,6]
> [1,] 0 1 0 1 1 0
> [2,] 1 0 0 1 1 0
> [3,] 0 0 0 0 1 1
> [4,] 1 1 0 0 1 0
> [5,] 1 1 1 1 0 0
> [6,] 0 0 1 0 0 0
>
> to gal object. How I do with spdep?

RSiteSearch("matrix listw")

gets you to several threads on the R-sig-geo list, suggesting in your case:

w <- mat2listw(wdat)
# convert matrix to spatial weights list write.nb.gal(w$neighbours, "wdat.gal")
# write neighbours component of spatial weights list as GAL file

Roger Bivand

>
> Thanks in advance for the help.
>
> Bernardo.
> University of ConcepciĆ³.
>
> ______________________________________________
> R-help <at> r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 22 Dec 2007 - 13:23:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 22 Dec 2007 - 14:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.