Skip to contents

Geometric Mean (GM)

Usage

gm(data, ...)

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

gm_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 gm_vec(), a single numeric value (or NA).

See also

Other descriptive statistics: cv()

Examples

library(tidyhydro)

gm
#> A Measure of Central Tendency

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

# Or as numeric vectors
gm_vec(avacha$obs)
#> [1] 128.9476