correct_ratio {baizer}R Documentation

correct the numbers to a target ratio

Description

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))

# support ratio as a float
correct_ratio(c(100, 100), c(0.2, 0.8))

# more numbers
correct_ratio(10:13, c(2, 3, 4, 6))

# with digits after decimal point
correct_ratio(c(10, 10), c(1, 4), digits = 1)

[Package baizer version 0.8.0 Index]