# geometricMean: Geometric mean In acidgenomics/basejump: Base Functions for Bioinformatics

## Description

The geometric mean is the nth root of n products or e to the mean log of `x`.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10``` ```geometricMean(object, ...) ## S4 method for signature 'numeric' geometricMean(object, removeNA = TRUE, zeroPropagate = FALSE) ## S4 method for signature 'matrix' geometricMean(object, MARGIN = 2L) ## S4 method for signature 'sparseMatrix' geometricMean(object, MARGIN = 2L) ```

## Arguments

 `object` Object. `removeNA` `logical(1)`. Remove `NA` values from calculations. `zeroPropagate` `logical(1)`. Allow propagation of zeroes. `MARGIN` a vector giving the subscripts which the function will be applied over. E.g., for a matrix `1` indicates rows, `2` indicates columns, `c(1, 2)` indicates rows and columns. Where `X` has named dimnames, it can be a character vector selecting dimension names. `...` Additional arguments.

## Details

Useful for describing non-normal (i.e. geometric) distributions.

## Value

`numeric`.

## Note

This function should be fully zero- and `NA`-tolerant. This calculation is not particularly useful if there are elements that are <= 0 and will return `NaN`.

Updated 2019-07-28.

• `psych::geometric.mean()`.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22``` ```## numeric ==== vec1 <- seq(1L, 5L, 1L) print(vec1) geometricMean(vec1) vec2 <- vec1 ^ 2L print(vec2) geometricMean(vec2) ## matrix ==== matrix <- matrix( data = c(vec1, vec2), ncol = 2L, byrow = FALSE ) print(matrix) geometricMean(matrix) ## sparseMatrix ==== sparse <- as(matrix, "sparseMatrix") print(sparse) geometricMean(sparse) ```