zones.sum | R Documentation |
zones.sum
computes the sum of y
for the
indices in each element of the list contained in zones
.
zones.sum(zones, y)
zones |
A list of nearest neighbors in the format
produced by |
y |
A numeric vector of values to be summed over. |
A numeric vector.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.