zones.sum: Sum over zones

Description Usage Arguments Value Examples

View source: R/zones.sum.R

Description

zones.sum computes the sum of y for the indices in each element of the list contained in zones.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# 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)

smerc documentation built on Oct. 1, 2021, 5:07 p.m.