geoMean

Compute the geometric mean of each row in a matrix x of variables (as columns). Copy and paste the function below to your R Console and hit enter. Afterwards, you can run the function by typing "geoMean(x)" where "x" is the m by n matrix of m specimens/taxa and n variables.

geoMean <- function(x){

X <- na.omit(x)

G <- exp(rowMeans(log(X),na.rm=T))

names(G) <- row.names(X)

return(G)

}

##### Function by Manabu Sakamoto, 2012: manabu.sakamoto@gmail.com