scale_to_reference_peak_frequency: Scale values so that the frequency of values < max(reference...

View source: R/sequence_characteristics.R

scale_to_reference_peak_frequencyR Documentation

Scale values so that the frequency of values < max(reference values) is the same as the frequency of reference values < max(reference values)

Description

Scale values so that the frequency of values < max(reference values) is the same as the frequency of reference values < max(reference values)

Usage

scale_to_reference_peak_frequency(x, x_ref, cap_at_peak = FALSE, na.rm = FALSE)

Arguments

x

Numeric vector. Values to scale.

x_ref

Numeric vector. Values from which the reference value is calculated.

cap_at_peak

A logical value. If TRUE, then scaled values larger than the reference peak value are reset to that peak value.

na.rm

A logical value. Argument is passed to fun.

Value

A numeric vector of the same length as x.

See Also

scale_to_reference_fun

Examples

x <- c(
  0.685, 0.698, 0.717, 1.026, 1.216, 1.239, 1.123, 1.104, 0.999,
  0.81, 0.652, 0.633
)
x0 <- c(0.5, 0.5, 0.5, 0.7, 0.9, 1, 1, 1, 0.9, 0.7, 0.5, 0.5)
x_scaled1 <- scale_to_reference_peak_frequency(x, x0, cap_at_peak = TRUE)
print(x_scaled1)

x_scaled2 <- scale_to_reference_peak_frequency(x, x0)
squash_into_low_high(x_scaled2, val_low = -Inf, val_high = max(x0))


DrylandEcology/rSW2utils documentation built on Dec. 9, 2023, 10:44 p.m.