| date_range | R Documentation |
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)
x |
The input date vector. Required |
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).
Edward Visel, Will Beasley
library(OuhscMunge)
date_min_with_nas(c(NA, NA, NA))
date_min_with_nas(as.Date(NA_character_))
date_min_with_nas(as.Date(character(0)))
date_min_with_nas(as.Date(c("2009-04-21", "2017-12-27", NA_character_)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.