I have a spatial weight file in csv that I want as listw object in R. The file has the following 3 variables (left to right in the file) -- OID_, NID and WEIGHTS. NID stands for the neighbors and OID_ as the origins. There are 217 origins with 4 neighbors each.
I have been able to read the csv file as a data frame (test.csv). Then I tried to check whether the OID_ variable is in the right place in the dataframe. I used "match" for that using: o <- match(OID_, OID_) I am not sure whether this is the right way to match. Please advice. Anyway, next I created a matrix object (m) using: m <- as.matrix(test.csv[, -1]) Then I created object m1, using: m1 <- m[o, o] Finally, I tried creating listw object using: mat2listw(m1) Here I get an error that x is not a square matrix. Not sure what to do now. Any helo appreciated! Thanks, Shishm ______________________________________________ R-help@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.