R/gMean.R

Defines functions gMean

Documented in gMean

#' Computes geometric mean using logarithms
#'
#' @export
#' @param Y matrix or vector
#' @param MARGIN input for \code{\link{apply}}

gMean <- function(Y,MARGIN=2){
  g <- apply(Y,MARGIN=MARGIN,FUN=function(y) exp(mean(log(y))))
  return(g)
}
reptalex/phylofactor documentation built on Feb. 28, 2024, 3:19 p.m.