robustmax: Robust maxima

Description Usage Arguments Details Value See Also

View source: R/Data_Mgt_Functions.R

Description

Returns the regular maxima of the input values x using max(x) except it just returns NA when x is an empty vector.

Usage

1
robustmax(x, na.rm = FALSE)

Arguments

x

Numeric or character arguments.

na.rm

A logical indicating whether missing values should be removed.

Details

=============================================================================

This function solves warnings issued by max() when it is used on an empty vector. Using max(numeric(0)) yields a warning "no non-missing arguments to max; returning -Inf" and is very slow about doing that. So, robustmax() is a replacement function that just returns NA when the vector is empty. That speeds things up dramatically.

Value

A length one vector. The type of the result will be that of the highest of the inputs in the hierarchy integer < double < character.

See Also

Extremes


sjpierce/SSACHR documentation built on Jan. 16, 2022, 12:39 a.m.