Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd NA_Date_ and 0-length Date helpers #681
Comments
|
This is a good idea but it's so fundamental that should be tried with base R first. I could add NA_date_ and Date to lubridate but then I will have to add NA_POSIXct_ and POSIXct for consistency. I feel that all these belong in R proper. |
|
I decided to add these. We already do is.Date and is.POSIXct. Even if accepted into the core it almost surely won't be treating the |
|
Hey -- sorry if this is obvious. But what is the workaround to not having NA_Date_ and needing to use if_else? The base R ifelse seems to breaks a lot of lubridate features. |
|
@yakyak462 See the original issue: |
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.