# gmean.R
# ::rtemis::
# 2022 E.D. Gennatas www.lambdamd.org
#' Geometric mean
#'
#' @param x Numeric vector
#'
#' @author E.D. Gennatas
#' @export
#' @examples
#' x <- c(1, 3, 5)
#' mean(x)
#' gmean(x)
#' # same as, but a little faster than:
#' exp(mean(log(x)))
gmean <- function(x) {
prod(x)^(1 / length(x))
} # rtemis::gmean
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.