rsd: Coefficient of Variation (Relative standard deviation)

View source: R/rsd.R

rsdR Documentation

Coefficient of Variation (Relative standard deviation)

Description

Calculates the coefficient of variation, also known as relative standard deviation, which is given by

sd(x)/mean(x)

Usage

rsd(x, as.percentage = TRUE, na.rm = TRUE, adjust = FALSE, adjust.lo = 1)

Arguments

x

Numeric: Input

as.percentage

Logical: If TRUE, multiply by 100

na.rm

Logical: If TRUE, remove missing values before computation

adjust

Logical: If TRUE, if x contains values < adjust.lo, x will be shifted up by adding its minimum

adjust.lo

Float: Threshold to be used if adjust = TRUE

Details

This is not meaningful if mean is close to 0. For such cases, set adjust = TRUE. This will add min(x) to x

Examples

## Not run: 
mplot3_x(sapply(1:100, function(x) cov(rnorm(100))), 'd', xlab = 'rnorm(100) x 100 times')
# cov of rnorm without adjustment is all over the place
mplot3_x(sapply(1:100, function(x) cov(rnorm(100), adjust = T)), 'd',
xlab = 'rnorm(100) x 100 times')
# COV after shifting above 1 is what you probably want

## End(Not run)

egenn/rtemis documentation built on Dec. 17, 2024, 6:16 p.m.