R/calc_geom_mean.R

Defines functions calc_geom_mean

Documented in calc_geom_mean

#' Calculate the geometric mean
#' @param values a numeric vector of values
#' @return returns the geometric mean if all values are at least zero,
#'   else returns NA
#' @author Richèl J.C. Bilderbeek
#' @export
calc_geom_mean <- function(values) {
  if (any(values < 0.0)) return(NA)
  exp(mean(log(values)))
}

Try the tracerer package in your browser

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

tracerer documentation built on Sept. 27, 2023, 5:09 p.m.