[R-sig-Geo] "dnearineigh" source code
Roger Bivand
Roger.Bivand at nhh.no
Wed Sep 7 21:25:57 CEST 2011
On Thu, 8 Sep 2011, Ebrahim Jahanshiri wrote:
> I need to look into the code for "dnearneigh" so that I could get an idea of
> how to make weight matrices for any observation (i) based on some criteria.
> But a look into the spdep pack pointed me to the "spdep.dll". Probably
> written in some other languages. So I guess my question is how can I see the
> actual code for this and indeed other functions.
Please see:
http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf
pp. 43-45 for a general answer. For all CRAN packages, the source code is
always available for current versions on the package page, and for earlier
versions in the archives. For some packages, including spdep, R-Forge
hosting means that the source code can also be browsed online, at:
https://r-forge.r-project.org/scm/viewvc.php/?root=spdep
However, you are almost certainly not approaching this in a sensible way,
as the glist= argument provides complete flexbility for adding arbitrary
general weights to an nb object - list of neighbours. You do not need
access to dnearneigh() internals to do this. If you want to define the
neighbours in some specific way not already provided, you need to create a
list of integer vectors of indices in the 1:n range for n observations,
coding no-neighbour observations with the single integer id 0, adding
class and other attributes.
Hope this helps,
Roger
>
> [The only answer I got by searching close to my problem is the answer by
> Prof. Bivand on the "lag.listw":
> http://r-sig-geo.2731867.n2.nabble.com/lag-listw-function-in-spdep-package-td2762785.html
> which belongs to 2006. ]
>
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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