From d81550d0cccae824cc748de48e7fd50ea8d8033a Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 16 Apr 2020 18:02:18 +0200 Subject: Make na.rm = FALSE the default for geomean() This makes more sense and is in line with mean() from base R. Adapt tests and update docs. --- docs/reference/geomean.html | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'docs/reference/geomean.html') diff --git a/docs/reference/geomean.html b/docs/reference/geomean.html index 469e12f..34befc3 100644 --- a/docs/reference/geomean.html +++ b/docs/reference/geomean.html @@ -8,11 +8,13 @@ Calculate the geometric mean — geomean • pfm + + @@ -32,16 +34,18 @@ - + +This function returns NA if NA values are present and na.rm = FALSE +(default). If negative values are present, it gives an error message. +If at least one element of the vector is 0, it returns 0." /> + @@ -85,7 +89,6 @@ returns 0 if at least one element of the vector is 0." /> Reference - @@ -107,16 +110,15 @@ returns 0 if at least one element of the vector is 0." />
-

Based on some posts in a thread on Stackoverflow http://stackoverflow.com/questions/2602583/geometric-mean-is-there-a-built-in -This function checks for negative values, removes NA values per default and -returns 0 if at least one element of the vector is 0.

- +This function returns NA if NA values are present and na.rm = FALSE +(default). If negative values are present, it gives an error message. +If at least one element of the vector is 0, it returns 0.

-
geomean(x, na.rm = TRUE)
- +
geomean(x, na.rm = FALSE)
+

Arguments

@@ -129,22 +131,19 @@ returns 0 if at least one element of the vector is 0.

Should NA values be omitted?

- +

Value

The geometric mean

-

Examples

-
geomean(c(1, 3, 9))
#> [1] 3
geomean(c(1, 3, NA, 9))
#> [1] 3
if (FALSE) geomean(c(1, -3, 9)) # returns an error
+
geomean(c(1, 3, 9))
#> [1] 3
geomean(c(1, 3, NA, 9))
#> [1] NA
if (FALSE) geomean(c(1, -3, 9)) # returns an error