reaggregate_rates()
converts rates over one interval range to another
with optional weighting by a known population.
Usage
reaggregate_rates(...)
# Default S3 method
reaggregate_rates(
bounds,
rates,
new_bounds,
...,
population_bounds = NULL,
population_weights = NULL
)
Arguments
- ...
Further arguments passed to or from other methods.
- bounds
[numeric]
The current boundaries in (strictly) increasing order.
These correspond to the left hand side of the intervals (e.g. the closed side of [x, y).
Double values are coerced to integer prior to categorisation.
- rates
[numeric]
Vector of rates corresponding to the intervals defined by
bounds
.- new_bounds
[numeric]
The desired boundaries in (strictly) increasing order.
- population_bounds
[numeric]
Interval boundaries for a known population weighting given by the
population_weights
argument.- population_weights
[numeric]
Population weightings corresponding to
population_bounds
.Used to weight the output across the desired intervals.
If
NULL
(default) rates are divided proportional to the interval sizes.
Examples
reaggregate_rates(
bounds = c(0, 5, 10),
rates = c(0.1, 0.2 ,0.3),
new_bounds = c(0, 2, 7, 10),
population_bounds = c(0, 2, 5, 7, 10),
population_weights = c(100, 200, 50, 150, 100)
)
#> # A tibble: 4 × 4
#> interval lower upper rate
#> <ord> <dbl> <dbl> <dbl>
#> 1 [0, 2) 0 2 0.1
#> 2 [2, 7) 2 7 0.12
#> 3 [7, 10) 7 10 0.2
#> 4 [10, Inf) 10 Inf 0.3