Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NA_Date_ and 0-length Date helpers #681

Closed
AshesITR opened this issue Jun 6, 2018 · 2 comments

Comments

@AshesITR
Copy link

commented Jun 6, 2018

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.

@vspinu

This comment has been minimized.

Copy link
Member

commented Jul 3, 2018

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.

@vspinu vspinu closed this in ea25ca6 Jul 3, 2018

@vspinu

This comment has been minimized.

Copy link
Member

commented Jul 3, 2018

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 tz argument as we want it - "UTC" by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.