hhh4contacts (version 0.13.1)

aggregateCountsArray: 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)

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.

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.

Author

Sebastian Meyer

Examples

Run this code
## 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)))

Run the code above in your browser using DataLab