Skip to contents

Calculates the arithmetic mean after excluding missing values. A fast, unsafe alternative to base::mean(x, na.rm = TRUE) for numeric vectors.

Usage

fmean(x)

Arguments

x

(numeric)
The numeric vector used to calculate the mean.

Value

Scalar numeric

See also

Examples

#----------------------------------------------------------------------------
# fmean() example
#----------------------------------------------------------------------------
library(bkbase)

fmean(1:3)
#> [1] 2
fmean(c(1:3, NA))
#> [1] 2
fmean(NA)
#> [1] NaN
fmean(numeric(0))
#> [1] NaN