[R-sig-Geo] Error with read.GWT2nb in making KNN weights symmetrical
Roger Bivand
Roger.Bivand at nhh.no
Sat Mar 19 21:04:34 CET 2011
On Thu, 17 Mar 2011, Kevin Wolff wrote:
> 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"
Well, R is case sensitive, and the function is named read.gwt2nb(), so the
error does seem plausible. Try using the right name. Tip - try ?<name> to
see if a function exists and is user-visible.
Roger
>
> 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"
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> 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