R/CV.R

Defines functions iqrCV medCV CV

Documented in CV iqrCV medCV

CV <- function(x, na.rm = FALSE){
  stopifnot(is.numeric(x))
  if(any(x <= 0))
    stop("Your data must be positive!")
  sd(x, na.rm = na.rm)/mean(x, na.rm = na.rm)
}

medCV <- function(x, na.rm = FALSE){
  stopifnot(is.numeric(x))
  if(any(x <= 0))
    stop("Your data must be positive!")
  mad(x, na.rm = na.rm)/median(x, na.rm = na.rm)
}

iqrCV <- function(x, na.rm = FALSE){
  stopifnot(is.numeric(x))
  if(any(x <= 0))
    stop("Your data must be positive!")
  sIQR(x, na.rm = na.rm)/median(x, na.rm = na.rm)
}

Try the MKmisc package in your browser

Any scripts or data that you put into this service are public.

MKmisc documentation built on Nov. 20, 2022, 1:05 a.m.