R/geomean.r

Defines functions geomean

Documented in geomean

# name:     geomean
# purpose:  computes geometic mean on inout
# input:    numeric vector
# output:   numeric vector
# note:

# ROXYGEN Documentation
#' Geometric Mean
#' @param x numeric value
#' @param na.rm logical (default to TRUE) to omit NA entries
#' @return Geometric mean of vector x
#' @export
#' @examples
#' set.seed(1234)
#' x = rlnorm(1000)
#' mean(x)
#' geomean(x)
geomean <- function(x, na.rm = FALSE)
{
  if(na.rm) x = x[!is.na(x)]
  exp(mean(log(x)))
}
qPharmetra/qpToolkit documentation built on May 24, 2023, 8:52 a.m.