Calculate the coefficient of variation (i.e. variation coefficient) for a vector.

cv(x, na.rm = FALSE)

Arguments

x

a numeric vector

na.rm

Passed directly to sd and mean.

Value

a scalar equal to \(\frac{s_{x}}{\overline{x}}\).

References

Weisstein, Eric W. "Variation Coefficient." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/VariationCoefficient.html

Examples

x <- 1:5 y <- c(x^2, NA) cv(x) > cv(y, na.rm = TRUE)
#> [1] FALSE