[R-sig-Geo] From Sparse Matrix to Listw

Roger Bivand Roger.Bivand at nhh.no
Thu Aug 19 23:41:10 CEST 2010


On Thu, 19 Aug 2010, Lata Rafael wrote:

> Dear all,
>
> I have a problem converting a large binary sparse weight matrix (62025 *
> 62025) of class dgT to listw

You mean in package Matrix, and as described in ?"TsparseMatrix-class"?

>
> Is there a function that creates a listw object from a sparse matrix?

>From the description, you should be able to work out how to convert such 
an object into a "spatial.neighbours" object (see listw2sn), then use 
sn2listw() to go the other way. Watch the attributes, as they need to be 
correct. Also note that the input object uses 0-base indices, but the sn 
object uses 1-base indices.

Hope this helps,

Roger

>
> Thank you in advance.
>
>
>
> Best regards
>
>
>
> Rafael Lata
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at 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.Bivand at nhh.no



More information about the R-sig-Geo mailing list