| Title: | Proportional Allocation with Sum Consistency |
|---|---|
| Description: | Provides robust functions for proportional allocation of numeric values. It guarantees sum consistency after rounding or integer truncation using one of two adjustment methods: the largest remainder method or max-value adjustment. Handles edge cases like NA weights and vector total values seamlessly. |
| Authors: | Shunsuke Homma [aut, cre] |
| Maintainer: | Shunsuke Homma <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-06-18 19:38:56 UTC |
| Source: | https://github.com/cran/proratar |
Proportional Allocation
prorate(total, weights, digits = NULL, adjust = c("each", "max", "none"))prorate(total, weights, digits = NULL, adjust = c("each", "max", "none"))
total |
Scalar numeric. The total value to allocate. |
weights |
Numeric vector of weights. NA values are automatically treated as zero. |
digits |
Integer. Number of decimal places to round to. Default is NULL (no rounding). |
adjust |
Character or Logical. Adjustment method for total sum consistency:
|
A numeric vector of allocated values.
Integer Proportional Allocation
prorate_int(total, weights, adjust = c("each", "max", "none"))prorate_int(total, weights, adjust = c("each", "max", "none"))
total |
Scalar numeric or integer. The total value to allocate. Must be a whole number. |
weights |
Numeric vector of weights. NA values are automatically treated as zero. |
adjust |
Character or Logical. Adjustment method for total sum consistency:
|
An integer vector of allocated values summing exactly to total.