Calculates the relative difference, defined as
$$\frac{\vert x - y \vert}{x} $$
between two arrays or data frames, where x
are considered reference values.
Usage
rel_diff(x, y, pct = TRUE, epsilon = 10 * .Machine$double.eps)
Arguments
- x
An array or data frame, considered the reference values
- y
Comparison array or data frame
- pct
Logical; if TRUE
the relative differences are multiplied by 100, giving values in percent difference from x
.
- epsilon
Threshold for values near zero
Value
An array or data frame the same size as x
and y
containing the relative differences
Examples
# example code
m1 <- cbind(c(0,1), c(1,1))
m2 <- cbind(c(0,1), c(1.01,1.11))
rel_diff(m1, m2, pct = FALSE)
#> Error in rel_diff(m1, m2, pct = FALSE): could not find function "rel_diff"
rel_diff(m1, m2)
#> Error in rel_diff(m1, m2): could not find function "rel_diff"