Subset a spatial weights list
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
).
## S3 method for class 'listw' subset(x, subset, zero.policy = NULL, ...)
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
col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1]) 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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.