Calculate relative standard deviations

rsd and rowRsd are convenience functions to calculate the relative standard deviation (i.e. coefficient of variation) of a numerical vector or for rows of a numerical matrix, respectively.

rsd(x, na.rm = TRUE, mad = FALSE)

rowRsd(x, na.rm = TRUE, mad = FALSE)

Arguments

x

for rsd a numeric, for rowRsd a numerical matrix.

na.rm

logical(1) whether missing values (NA) should be removed prior to the calculations.

mad

logical(1) whether the Median Absolute Deviation (MAD) should be used instead of the standard deviation. This is suggested for non-gaussian distributed data.

Author

Johannes Rainer

Examples

a <- c(4.3, 4.5, 3.6, 5.3) rsd(a)
#> [1] 0.1580575
A <- rbind(a, a, a) rowRsd(A)
#> a a a #> 0.1580575 0.1580575 0.1580575