Skip to content
Prev 11094 / 29559 Next

spdep: show neighbors from "dnearneigh"

On Fri, 4 Mar 2011, Kevin Ringelman wrote:

            
In S and R, objects with a class attribute, such as "nb" objects, may have 
display methods specific to the class. If you just say:
then this is expanded internally to print(nb), and since nb is an object 
of class "nb", the print.nb() method is chosen. If you want the default 
print method, call it as print.default(nb). Conversion of objects of one 
class to another class may be done by coercion where coercion methods are 
provided. No such methods are available for nb objects. There are 
functions to do things like this, but not methods. For example, to make an 
nb object into a row-standardised matrix, you might do:
but you should avoid this if your number of observations is large. To make 
a sparse matrix, several steps are required:
using the nb2listw() and (ugly name) as_dgRMatrix_listw() functions, and 
coercion from one representation to another using new-style classes 
defined in the Matrix package.
Note that an nb object is a list - to nuke the class, do:
which lets you call print.default(), but to get at the attribute you want, 
just do:
to call print.default on the character vector it contains.

Hope this clarifies,

Roger