Description Usage Arguments Value Author(s) See Also Examples
Convert neighborhood structure objects of class "nb"
from R-package spdep to graph
objects of class "gra"
from R-package R2BayesX and vice versa.
1 2 |
nbObject |
neighborhood structure object of class |
graObject |
graph object of class |
Equivalent object in the other format.
Daniel Sabanes Bove.
sp2bnd
, bnd2sp
for conversion between the geographical information
formats and read.gra
, write.gra
for the interface to the
R2BayesX files.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## first nb to gra:
if(require("spdep")) {
example(columbus)
colNb <- poly2nb(columbus)
## ... here manual editing is possible ...
## then export to graph format
colGra <- nb2gra(colNb)
## and save in BayesX file
graFile <- tempfile()
write.gra(colGra, file=graFile)
## now back from gra to nb:
colGra <- read.gra(graFile)
newColNb <- gra2nb(colGra)
newColNb
## compare this with the original
colNb
## only the call attribute does not match (which is OK):
all.equal(newColNb, colNb, check.attributes = FALSE)
attr(newColNb, "call")
attr(colNb, "call")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.