proportionate: A Number Multiplies Proportions Under Limitations

View source: R/proportionate.R

proportionateR Documentation

A Number Multiplies Proportions Under Limitations

Description

A Number Multiplies Proportions Under Limitations

Usage

proportionate(
  number,
  result_sum_strict = NULL,
  prop,
  prop_sum_strict = NULL,
  digits = 0
)

Arguments

number

A number

result_sum_strict

The limitation of the sum of results

prop

The proportions to be multiplied by the number

prop_sum_strict

The limitation of the sum of proportions

digits

The number of decimal places

Examples

## Save 1 decimal place
a <- proportionate(number = 355,
                   prop = c(0.2, 0.6, 0.15, 0.36),
                   digits = 1)
## The sum of the proportions is 1
b <- proportionate(number = 355,
                   prop = c(0.2, 0.6, 0.15, 0.05),
                   prop_sum_strict = 1,
                   digits = 1)
## Save 0 decimal place
c <- proportionate(number = 355,
                   prop = c(0.2, 0.6, 0.15, 0.05),
                   prop_sum_strict = 1,
                   digits = 0)
## The sum of the results is 355
d <- proportionate(number = 355,
                   result_sum_strict = 355,
                   prop = c(0.2, 0.6, 0.15, 0.05),
                   prop_sum_strict = 1,
                   digits = 0)

duohongrui/simutils documentation built on March 12, 2024, 8:40 p.m.