Sometimes I find the need to explicitly set a date to NA (or specify an empty Date vector).
The former would be
NA_Date_ <- structure(NA_real_, class = "Date")
This is especially useful in conjuction with dplyr::if_else wich will error out on
dplyr::if_else(FALSE, NA_real_, lubridate::today()) and any other NA_...
The latter would be
Date <- function(length = 0L)structure(rep(NA_real_, length), class = "Date")
wich is very useful in allocating an empty data.frame with a date column.
Sometimes I find the need to explicitly set a date to NA (or specify an empty Date vector).
The former would be
NA_Date_ <- structure(NA_real_, class = "Date")This is especially useful in conjuction with
dplyr::if_elsewich will error out ondplyr::if_else(FALSE, NA_real_, lubridate::today())and any other NA_...The latter would be
Date <- function(length = 0L)structure(rep(NA_real_, length), class = "Date")wich is very useful in allocating an empty data.frame with a date column.