rescale_integer_sum {migest} | R Documentation |
Rescale integer vector to a set sum
Description
For when you want to rescale a set of numbers to sum to a given value and do not want all rescaled values to be integers.
Usage
rescale_integer_sum(x, tot)
Arguments
x |
Vector of numeric values |
tot |
Numeric integer value to rescale sum to. |
Value
Vector or integer values that sum to to tot
Author(s)
Guy J. Abel
See Also
Examples
x <- rnorm(n = 10, mean = 5, sd = 20)
y <- rescale_integer_sum(x, tot = 10)
y
sum(y)
for(i in 1:10){
y <- rescale_integer_sum(x = rpois(n = 10, lambda = 10), tot = 1000)
print(sum(y))
}
[Package migest version 2.0.4 Index]