reaggregate_interval_counts {ageutils} | R Documentation |
Reaggregate age intervals
Description
reaggregate_interval_counts()
converts counts over one interval range to
another. It first splits counts of a given age interval in to counts for
individual years based on a given weighting. These are then aggregated to the
desired breaks. Functionally this is equivalent to, but more efficient than,
a call to split_interval_counts()
followed by aggregate_age_counts()
.
Usage
reaggregate_interval_counts(
lower_bounds,
upper_bounds,
counts,
breaks,
max_upper = 100L,
weights = NULL
)
Arguments
lower_bounds , upper_bounds |
A pair of vectors representing the bounds of the intervals.
Missing (NA) bounds are not permitted. Double vectors will be coerced to integer. |
counts |
Vector of counts to be aggregated. |
breaks |
1 or more cut points in increasing (strictly) order. These correspond to the left hand side of the desired intervals (e.g. the closed side of [x, y). Double values are coerced to integer prior to categorisation. |
max_upper |
Represents the maximum upper bounds permitted upon splitting the data. Any upper bound greater than this will be replaced with this value prior to splitting. Double vectors will be coerced to integer. |
weights |
Population weightings to apply for individual years. If If specified, must be of length |
Value
A data frame with 4 entries; interval
, lower_bound
, upper_bound
and an
associated count
.
Examples
reaggregate_interval_counts(
lower_bounds = c(0, 5, 10),
upper_bounds = c(5, 10, 20),
counts = c(5, 10, 30),
breaks = c(0L, 1L, 5L, 15L, 25L, 45L, 65L)
)