1% Copyright 2004 by Roger S. Bivand
2\name{subset.listw}
3\alias{subset.listw}
4\title{Subset a spatial weights list}
5\description{
6  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 \code{nb2listw} with \code{glist=NULL}).}
7\usage{
8\method{subset}{listw}(x, subset, zero.policy = NULL, ...)
9}
10
11\arguments{
12  \item{x}{an object of class \code{listw}}
13  \item{subset}{logical expression}
14  \item{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 \code{nb2listw}}
15  \item{\dots}{generic function pass-through}
16}
17\value{
18  The function returns an object of class \code{listw} with component \code{style} the same as the input object, component \code{neighbours} a list of integer vectors containing neighbour region number ids (compacted to run from 1:number of regions in subset), and component \code{weights} as the weights computed for \code{neighbours} using \code{style}.
19}
20\author{Roger Bivand \email{Roger.Bivand@nhh.no}}
21\seealso{\code{\link{nb2listw}}, \code{\link{subset.nb}}}
22
23
24\examples{
25col.gal.nb <- read.gal(system.file("weights/columbus.gal", package="spData")[1])
26to.be.dropped <- c(31, 34, 36, 39, 42, 46)
27pre <- nb2listw(col.gal.nb)
28print(pre)
29post <- subset(pre, !(1:length(col.gal.nb) \%in\% to.be.dropped))
30print(post)
31}
32\keyword{spatial}
33