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.
Examples
x <- rnorm(n = 10, mean = 5, sd = 20)
y <- rescale_integer_sum(x, tot = 10)
y
#> [1] 0 -1 2 2 0 0 1 4 4 -2
sum(y)
#> [1] 10
for(i in 1:10){
y <- rescale_integer_sum(x = rpois(n = 10, lambda = 10), tot = 1000)
print(sum(y))
}
#> [1] 1000
#> [1] 1000
#> [1] 1000
#> [1] 1000
#> [1] 1000
#> [1] 1000
#> [1] 1000
#> [1] 1000
#> [1] 1000
#> [1] 1000