npcv: Non-parametric coefficient of variation

Description Usage Arguments Details Value Author(s) Examples

View source: R/utils.R

Description

Calculates a non-parametric version of the coefficient of variation where the standard deviation is replaced by the median absolute deviations (see mad for details) and divided by the absolute value of the mean.

Usage

1
npcv(x, na.rm = TRUE)

Arguments

x

A numeric.

na.rm

A logical (default is TRUE indicating whether NA values should be stripped before the computation of the median absolute deviation and mean.

Details

Note that the mad of a single value is 0 (as opposed to NA for the standard deviation, see example below).

Value

A numeric.

Author(s)

Laurent Gatto

Examples

1
2
3
4
5
6
set.seed(1)
npcv(rnorm(10))
replicate(10, npcv(rnorm(10)))
npcv(1)
mad(1)
sd(1)

Example output

Loading required package: BiocGenerics
Loading required package: parallel

Attaching package:BiocGenericsThe following objects are masked frompackage:parallel:

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked frompackage:stats:

    IQR, mad, sd, var, xtabs

The following objects are masked frompackage:base:

    anyDuplicated, append, as.data.frame, basename, cbind, colnames,
    dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
    grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
    order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
    rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
    union, unique, unsplit, which.max, which.min

Loading required package: Biobase
Welcome to Bioconductor

    Vignettes contain introductory material; view with
    'browseVignettes()'. To cite Bioconductor, see
    'citation("Biobase")', and for packages 'citation("pkgname")'.

Loading required package: mzR
Loading required package: Rcpp
Loading required package: S4Vectors
Loading required package: stats4

Attaching package:S4VectorsThe following object is masked frompackage:base:

    expand.grid

Loading required package: ProtGenerics

Attaching package:ProtGenericsThe following object is masked frompackage:stats:

    smooth


This is MSnbase version 2.16.0 
  Visit https://lgatto.github.io/MSnbase/ to get started.


Attaching package:MSnbaseThe following object is masked frompackage:base:

    trimws

[1] 5.852407
 [1]  3.112625  6.088948  4.928480  5.534139  6.124995  2.354319  2.996464
 [8]  6.049891 11.716089  3.265193
[1] 0
[1] 0
[1] NA

MSnbase documentation built on Jan. 23, 2021, 2 a.m.