File: aggregate.nb.Rd

package info (click to toggle)
r-cran-spdep 1.1-5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,012 kB
  • sloc: ansic: 1,489; sh: 16; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,460 bytes parent folder | download | duplicates (4)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
\name{aggregate.nb}
\alias{aggregate.nb}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Aggregate a spatial neighbours object}
\description{
  The method aggregates a spatial neighbours object, creating a new object listing the neighbours of the aggregates.
}
\usage{
\method{aggregate}{nb}(x, IDs, remove.self = TRUE, ...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{x}{an nb neighbour object}
  \item{IDs}{a character vector of IDs grouping the members of the neighbour object}
  \item{remove.self}{default TRUE: remove self-neighbours resulting from aggregation}
  \item{\dots}{unused - arguments passed through}
}

\value{
  an nb neighbour object, with empty aggregates dropped.
}

\author{Roger Bivand \email{Roger.Bivand@nhh.no}}
\note{Method suggested by Roberto Patuelli}

\examples{
data(used.cars, package="spData")
data(state)
cont_st <- match(attr(usa48.nb, "region.id"), state.abb)
cents <- as.matrix(as.data.frame(state.center))[cont_st,]
opar <- par(mfrow=c(2,1))
plot(usa48.nb, cents, xlim=c(-125, -65), ylim=c(25, 50))
IDs <- as.character(state.division[cont_st])
agg_cents <- aggregate(cents, list(IDs), mean)
agg_nb <- aggregate(usa48.nb, IDs)
plot(agg_nb, agg_cents[, 2:3], xlim=c(-125, -65), ylim=c(25, 50))
text(agg_cents[, 2:3], agg_cents[, 1], cex=0.6)
par(opar)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{spatial}