zones.sum: Sum over zones

View source: R/zones.sum.R

zones.sumR 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 scan.zones.

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)

jfrench/smerc documentation built on Oct. 27, 2024, 5:13 p.m.