Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

calcGM

Calculate the Geometric Mean, Allowing for Zeroes


Description

Calculate the geometric mean of a numeric vector, possibly excluding zeroes and/or adding an offset to compensate for zero values.

Usage

calcGM(x, offset = 0, exzero = TRUE)

Arguments

x

vector of numbers

offset

value to add to all components, including zeroes

exzero

if TRUE, exclude zeroes (but still add the offset)

Value

Geometric mean of the modified vector x + offset

Note

NA values are automatically removed from x

Author(s)

Rowan Haigh, Pacific Biological Station, Fisheries and Oceans Canada, Nanaimo BC

Examples

local(envir=.PBSmodEnv,expr={
  calcGM(c(0,1,100))
  calcGM(c(0,1,100),offset=0.01,exzero=FALSE)
})

PBSmodelling

GUI Tools Made Easy: Interact with Models and Explore Data

v2.68.8
GPL (>= 2)
Authors
Jon T. Schnute [aut], Alex Couture-Beil [aut], Rowan Haigh [aut, cre], Nicholas Boers [ctb], Anisa Egeli [ctb], A. R. Kronlund [ctb], Steve Martell [ctb], Norm Olsen [ctb]
Initial release
2019-03-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.