safe_mean: Calculate mean but return NA rather than NaN when values are missing
Description
This function is a drop-in replacement for mean, which is used in
cat_summarise. It returns NA rather than NaN when all values are NA.
Usage
safe_mean(x, na.rm = FALSE)
Value
The mean of x or NA when values are missing.
Arguments
- x
A numerical vector.
- na.rm
A boolean indicating whether to remove NAs.