Description Usage Arguments Value Author(s) See Also Examples
The function subsets a neighbors list, retaining objects for which the subset argument vector is TRUE.
1 2 |
x |
an object of class |
subset |
logical expression |
... |
generic function pass-through |
The function returns an object of class nb
with a list of
integer vectors containing neighbour region number ids (compacted to
run from 1:number of regions in subset).
Roger Bivand Roger.Bivand@nhh.no
1 2 3 4 5 6 7 8 9 10 11 | example(columbus)
coords <- coordinates(columbus)
plot(col.gal.nb, coords)
to.be.dropped <- c(31, 34, 36, 39, 42, 46)
text(coords[to.be.dropped,1], coords[to.be.dropped,2], labels=to.be.dropped,
pos=2, offset=0.3)
sub.col.gal.nb <- subset(col.gal.nb,
!(1:length(col.gal.nb) %in% to.be.dropped))
plot(sub.col.gal.nb, coords[-to.be.dropped,], col="red", add=TRUE)
which(!(attr(col.gal.nb, "region.id") %in%
attr(sub.col.gal.nb, "region.id")))
|
Loading required package: sp
Loading required package: Matrix
colmbs> require(maptools)
Loading required package: maptools
Checking rgeos availability: TRUE
colmbs> columbus <- readShapePoly(system.file("etc/shapes/columbus.shp",
colmbs+ package="spdep")[1])
colmbs> col.gal.nb <- read.gal(system.file("etc/weights/columbus.gal",
colmbs+ package="spdep")[1])
Warning message:
use rgdal::readOGR or sf::st_read
[1] 31 34 36 39 42 46
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.