rsd: Relative standard deviation

View source: R/mt_extra.R

rsdR Documentation

Relative standard deviation

Description

Calculate Relative Standard Deviation(RSD). RSD is also known as the coefficient of variation (CV)

Usage

rsd(x, na.rm = TRUE)

Arguments

x

an vector, matrix or data frame.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

Details

Some notes:

  • The higher the CV, the greater the dispersion in the variable.

  • The CV is often presented as the given ratio multiplied by 100

  • Basically CV<10 is very good, 10-20 is good, 20-30 is acceptable, and CV>30 is not acceptable.

Value

RSD value multiplied by 100.

Examples

library(ggplot2)
library(dplyr)
library(tidyr)
library(purrr)

data(iris)
rsd(iris[, 1:4])

## group rsd
val <- iris %>% 
  group_by(Species) %>% 
	 group_modify(~ dat_summ(., method = rsd)) %>%
  pivot_longer(cols = !Species) %>% filter(!is.na(value))

ggplot(val, aes(x = value)) +
  geom_histogram(colour = "black", fill = "white") +
  facet_grid(Species ~ .)
ggplot(val, aes(x = Species, y = value)) + geom_boxplot()

## The plotting of missing value is similar like this.

wanchanglin/mtExtra documentation built on Aug. 2, 2024, 5:47 p.m.