zones.sum {smerc} | R Documentation |
Sum over zones
Description
zones.sum
computes the sum of y
for the
indices in each element of the list contained in zones
.
Usage
zones.sum(zones, y)
Arguments
zones |
A list of nearest neighbors in the format
produced by |
y |
A numeric vector of values to be summed over. |
Value
A numeric vector.
Examples
# show nn.cumsum example for a circular scan setting
data(nydf)
coords <- with(nydf, cbind(longitude, latitude))
cases <- floor(nydf$cases)
zones <- scan.zones(coords, pop = nydf$pop, ubpop = 0.1)
# compute cumulative sums over all nn
szones <- zones.sum(zones, cases)
# compute cumulative sums over just the first set of nn
szones2 <- sapply(zones, function(x) sum(cases[x]))
# check equality
all.equal(szones, szones2)
[Package smerc version 1.8.3 Index]