safe_max | R Documentation |
Modified version of base::max()
that differs in the following ways:
NA
s in the input (...
) are ignored by default (rm_na = TRUE
).
If the input is of length zero, the output will also be of length zero (of the same type as the input).
It is ensured that all inputs are either numeric, of length zero or NA
. The only case where the return value will be -Inf
or NA
is when the input
contains only -Inf
or NA
.
Dynamic dots are supported.
safe_max(..., rm_na = TRUE)
... |
Numeric objects of which to determine the maximum. Dynamic dots are supported. |
rm_na |
Ignore missing values in |
A numeric scalar or empty value, of the same type as ...
.
Other statistical computing / numeric functions:
round_to()
,
safe_min()
,
safe_seq_len()
,
stat_mode()
# other than `base::max()`, this function removes `NA`s by default
max(1, NA_real_, 2)
pal::safe_max(1, NA_real_, 2)
# other than `base::max()`, this function does not return `-Inf` or `NA_character_` for
# zero-length inputs
max(NULL)
max(integer())
pal::safe_max(NULL)
pal::safe_max(integer())
# other than `base::max()`, this function fails for non-numeric inputs
max("zero", 1L)
max("zero", "one")
max(character())
try(pal::safe_max("zero", 1L))
try(pal::safe_max("zero", "one"))
try(pal::safe_max(character()))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.