aggregateCountsArray: Aggregate an Array of Counts wrt One Dimension (Stratum)

aggregateCountsArrayR Documentation

Aggregate an Array of Counts wrt One Dimension (Stratum)

Description

Aggregate an Array of Counts wrt One Dimension (Stratum)

Usage

aggregateCountsArray(counts, dim, grouping, ..., sort = TRUE)

Arguments

counts

an (integer) array of counts with dimnames, e.g., counts or pop2011.

dim

the dimension index of the stratum defining groups.

grouping, ...

how the groups should be built.

sort

logical indicating if the resulting array should be ordered by the grouping levels in the dim dimension.

Value

an array with similar dimensions as the input counts except for the dim dimension, which will be smaller due to the aggregation as specified by the grouping argument.

Author(s)

Sebastian Meyer

Examples

## works for matrices
aggregateCountsArray(pop2011, dim = 2, grouping = c(2,1,3,2,4))
aggregateCountsArray(pop2011, dim = 1, grouping = list(
    "a" = c("chwi","span","zehl"),
    "b" = c("neuk","scho")
))
## and of course for arrays
str(aggregateCountsArray(counts, dim = 3, grouping = c(1, 3, 4)))

hhh4contacts documentation built on Oct. 8, 2024, 1:08 a.m.