Hello,

I am still fairly new to spatial data analysis using R and would appreciate
any help the list might be able to provide.  I have been using Roger's code
to bring ArcGIS Spatial Weights Matrices into R (see below).  However, when
I go to run spatial lag models, I get the following error: 

"NAs are not allowed in subscripted assignments"

I have tried the various na.action arguments to no avail.  Note that the
objects seem to work fine for Moran's I tests.  Does anybody know how to
solve this problem?

Thanks in advance,
Scott

Roger's Script for bringing Arc SWMs into R and making them list objects:

library(foreign)
x <- read.dbf("spatialweightmatrix3.dbf")
from_IDs <- sort(unique(x$FID2))
to_IDs <- sort(unique(x$NID))
# find the IDs used
all.equal(from_IDs, to_IDs)
o <- order(x$FID2, x$NID)
# order the object
xx <- x[o,]
# convert manually to a spatial.neighbours representation
sn <- data.frame(from=match(xx$FID2, from_IDs), to=match(xx$NID+1,
   to_IDs), weihts=xx$WEIGHT)
attr(sn, "n") <- length(from_IDs)
attr(sn, "region.id") <- as.character(from_IDs)
class(sn) <- c("spatial.neighbour", class(sn))
library(spdep)
lw <- sn2listw(sn)
lw
summary(sapply(lw$weights, sum))
table(card(lw$neighbours))

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to