[R-sig-Geo] spdep: From matrix to listw
Roger Bivand
Roger.Bivand at nhh.no
Fri Apr 20 15:47:59 CEST 2007
On Fri, 20 Apr 2007 mreisman at wu-wien.ac.at wrote:
> Dear colleagues,
>
> Is there any quick way for converting from R-matrix to listw-object of style 'W'
> (row-standardized)?
What is your R-matrix? mat2listw() assigns style "M" because it does not
know what the user has put in the input matrix. If you know that the row
sums are all unity, you could just overwite the object's style:
library(spdep)
data(columbus)
lw <- nb2listw(col.gal.nb, style="W")
lw$style
all(sapply(lw$weights, sum) == 1)
m <- listw2mat(lw)
all(apply(m, 1, sum) == 1)
lw1 <- mat2listw(m)
lw1$style
all(sapply(lw1$weights, sum) == 1)
lw1$style <- "W"
Roger
> I tried mat2listw but the result is style 'M' (which is not what I need).
> I also wrote my own GAL-file writer and went through read.gal and nb2listw
> (much to slow).
>
> Any suggestions?
>
> Regards,
> Martin Reismann
>
>
--
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