Skip to contents

Coefficient of Variation (Cv)

Usage

cv(data, ...)

# S3 method for class 'data.frame'
cv(data, truth, na_rm = TRUE, ...)

cv_vec(truth, na_rm = TRUE, ...)

Arguments

data

A data.frame containing the columns specified by the truth and estimate arguments.

...

Not currently used.

truth

The column identifier for the true results (that is numeric). This should be an unquoted column name although this argument is passed by expression and supports quasiquotation (you can unquote column names). For _vec() functions, a numeric vector.

na_rm

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

Value

A tibble with columns .metric, .estimator, and .estimate and 1 row of values.

For grouped data frames, the number of rows returned will be the same as the number of groups.

For cv_vec(), a single numeric value (or NA).

See also

Other descriptive statistics: gm()

Examples

library(tidyhydro)

cv
#> A Measure of Variability

# Supply truth as bare column names
cv(avacha, obs)
#> # A tibble: 1 × 3
#>   .metric .estimator .estimate
#>   <chr>   <chr>          <dbl>
#> 1 cv      standard       0.533

# Or as numeric vectors
cv_vec(avacha$obs)
#> [1] 0.5327502