Description Usage Arguments Value Author(s) See Also Examples
The function subsets a spatial weights list, retaining objects for which the subset argument vector is TRUE. At present it will only subset non-general weights lists (that is those created by nb2listw
with glist=NULL
).
1 2 |
x |
an object of class |
subset |
logical expression |
zero.policy |
default NULL, use global option value; if FALSE stop with error for any empty neighbour sets, if TRUE permit the weights list to be formed with zero-length weights vectors - passed through to |
... |
generic function pass-through |
The function returns an object of class listw
with component style
the same as the input object, component neighbours
a list of integer vectors containing neighbour region number ids (compacted to run from 1:number of regions in subset), and component weights
as the weights computed for neighbours
using style
.
Roger Bivand Roger.Bivand@nhh.no
1 2 3 4 5 6 | example(columbus)
to.be.dropped <- c(31, 34, 36, 39, 42, 46)
pre <- nb2listw(col.gal.nb)
print(pre)
post <- subset(pre, !(1:length(col.gal.nb) %in% to.be.dropped))
print(post)
|
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
Characteristics of weights list object:
Neighbour list object:
Number of regions: 49
Number of nonzero links: 230
Percentage nonzero weights: 9.579342
Average number of links: 4.693878
Weights style: W
Weights constants summary:
n nn S0 S1 S2
W 49 2401 49 23.48489 204.6687
Characteristics of weights list object:
Neighbour list object:
Number of regions: 43
Number of nonzero links: 212
Percentage nonzero weights: 11.46566
Average number of links: 4.930233
Weights style: W
Weights constants summary:
n nn S0 S1 S2
W 43 1849 43 19.26584 178.4604
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.