Return NA
for the min and max of a date vector if no nonmissing values are present.
date_min_with_nas(x)
date_max_with_nas(x)
date_range_with_nas(x)
min_with_nas_numeric(x)
max_with_nas_numeric(x)
range_with_nas_numeric(x)
min_with_nas_integer(x)
max_with_nas_integer(x)
range_with_nas_integer(x)
A date value, that's possibly NA
.
This function is a workaround for a weakness in base::min.date()
and base::max.date()
.
If no nonmissing values are present, both functions return +/-Inf
, but print NA
.
These two function return and print NA
, which behaves like SQL
(and probably matches the expectations of most users).
See Stack Overflow Questions Using dplyr::group_by() to find min dates with NAs
and R Inf
when it has class Date
is printing NA
.
The foundation of these functions was proposed in a response by Edward Visel (SO username alistaire).