Learn R Programming

GE (version 0.1.1)

ratio_adjust: Ratio Adjustment

Description

Adjust ratios to new values.

Usage

ratio_adjust(
  ratio,
  coef = 0.8,
  method = c("log", "left.linear", "max", "linear")
)

Arguments

ratio

a positive numeric vector.

coef

a positive number.

method

a character string specifying the adjustment method.

Value

A vector.

Details

For a positive ratio and the following methods, the return values are as follows:

  • log : coef * log(ratio) + 1, if ratio >= 1; 1 / (coef * log(1 / ratio) + 1), if ratio < 1.

  • left.linear : 1 / (coef * (1 / ratio - 1) + 1), if ratio >= 1; 1 + coef * (ratio - 1), if ratio < 1.

  • max : max(coef * log(ratio) + 1, 0).

  • linear : coef * (ratio - 1) + 1.

Examples

Run this code
# NOT RUN {
ratio_adjust(10, 0.8)
ratio_adjust(0.1, 0.8)

x <- seq(0.01, 2, 0.01)
plot(x, x, type = "l")
lines(x, ratio_adjust(x, 0.8, method = "log"), col = "red")
lines(x, ratio_adjust(x, 0.8, method = "left.linear"), col = "blue")
lines(x, ratio_adjust(x, 0.8, method = "max"), col = "green")

# }

Run the code above in your browser using DataLab