Skip to contents

correct the numbers to a target ratio

Usage

correct_ratio(raw, target, digits = 0)

Arguments

raw

the raw numbers

target

the target ratio

digits

the result digits

Value

corrected number vector

Examples

correct_ratio(c(10, 10), c(3, 5))
#> [1]  6 10

# support ratio as a float
correct_ratio(c(100, 100), c(0.2, 0.8))
#> [1]  25 100

# more numbers
correct_ratio(10:13, c(2, 3, 4, 6))
#> [1]  4  6  9 13

# with digits after decimal point
correct_ratio(c(10, 10), c(1, 4), digits = 1)
#> [1]  2.5 10.0