[R-sig-Geo] Export matrix weights to excel.

Roger Bivand Roger.Bivand at nhh.no
Sun May 4 19:46:20 CEST 2014


On Sat, 3 May 2014, Rolando Valdez wrote:

> Hello,
>
> I'm working with a matrix weights, I want to know if I can export the 
> output, to handle with excel.
>
> This is a part what I have:
>
>> zm <- readOGR(".", "zmdis”)
> OGR data source with driver: ESRI Shapefile
> Source: ".", layer: "zmdis"
> with 56 features and 8 fields
> Feature type: wkbPolygon with 2 dimensions
>> mapaxy = coordinates(zm)
>> wdist100 = dnearneigh(mapaxy, d1=0, d2=100000)
>> l100 = nb2listw(wdist100, style="W", zero.policy=T)
>> summary(l100, zero.policy=T)
> Characteristics of weights list object:
> Neighbour list object:
> Number of regions: 56
> Number of nonzero links: 86
> Percentage nonzero weights: 2.742347
> Average number of links: 1.535714
> 21 regions with no links:
> 3 6 11 13 14 15 16 24 25 27 28 35 36 38 41 47 48 51 52 53 54
> Link number distribution:
>
> 0  1  2  3  4  5  8
> 21 12 11  2  7  2  1
> 12 least connected regions:
> 1 5 7 17 19 20 21 30 33 34 45 55 with 1 link
> 1 most connected region:
> 37 with 8 links
>
> Weights style: W
> Weights constants summary:
>   n   nn S0       S1    S2
> W 35 1225 35 39.26667 147.3
>
> I want to get a matrix [56 x 56] to work in excel with it.

?listw2mat should help, then write the matrix in a form that Excel can 
read. But note that your distance criterion leaves 21 of 56 observations 
with no neighbours.

Hope this helps,

Roger

>
> Thank you in advance.
>
> Rolando Valdez
>
> _______________________________________________
> 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


More information about the R-sig-Geo mailing list