[R-sig-Geo] Error with read.GWT2nb in making KNN weights symmetrical

Kevin Wolff ktw08 at fsu.edu
Thu Mar 17 19:35:58 CET 2011


Hi all, 

I have worked with R before, but admittedly not in some time.  What I am trying to do is take my Geoda Nearest Neighbors Spatial weights files and make them symmetrical in order to use the Spatial Lag and Spatial Error functions in Geoda. Roger has been kind enough to help with this in the past and I have the code to do it.  The issue I am facing currently is getting R to run the code specified.  I run the first line 
knngwt <- read.GWT2nb("1503_NN.GWT", region.id=NULL ) and get the following error:
 "Error: could not find function "read.GWT2nb"

I have installed the newest version of R (2.12) as well as installed the maptools and spdep packages which seem to run okay. 
install.packages("maptools",dependencies=TRUE)
install.packages("spdep",dependencies=TRUE)

But when I put the syntax in I get that error message.  This may be due to an error on my part in installing the required packages, but I have tried everything I have come across to no avail. I appreciate any guidance in this matter. The full code, that I am attempting to run is below.  Thank you again.   Kevin

knngwt <- read.GWT2nb("1503_NN.GWT", region.id=NULL )
class(knngwt) # "nb"
summary(knngwt)
print(is.symmetric.nb(knngwt))
knngwtsym <- make.sym.nb(knngwt)
class(knngwtsym) # "nb"
print(is.symmetric.nb(knngwtsym))
listw1 <- nb2listw(knngwtsym, style="B")
class(listw1) # "listw"
knngwtsymsn <- listw2sn(listw1)
class(knngwtsymsn) # "spatial.neighbour"
write.sn2gwt(knngwtsymsn, "1503_NN_SYM.GWT"



More information about the R-sig-Geo mailing list