Learn R Programming

baizer (version 0.8.0)

correct_ratio: correct the numbers to a target ratio

Description

correct the numbers to a target ratio

Usage

correct_ratio(raw, target, digits = 0)

Value

corrected number vector

Arguments

raw

the raw numbers

target

the target ratio

digits

the result digits

Examples

Run this code
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)

Run the code above in your browser using DataLab