-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Labels
featurea feature request or enhancementa feature request or enhancementhelp wanted ❤️we'd love your help!we'd love your help!
Milestone
Description
Originally discussed in tidyverse/ggplot2#980 (comment); it seems as there is some need for flexibility of date and time transformations. These transformations are currently harder to program with than plain numerical transformations, as the date/time transformations have strict requirements on the class of the input data.
@yutannihilation made two excellent suggestions which I'll repeat here.
- Let the
domainpart of the transformation be of the same class as the expected input data. This in particular would allow a solution to a longstanding issue in ggplot2. - Let
date_trans()$transform()andtime_trans()$transform()accept numeric values. This would solve the aforementioned issue, as well as some others.
I understand that the class requirements protect against unintentional mistakes so I'd like to mention a 3rd idea.
- Add
...arguments to alltrans$transform()arguments and in addition aforceargument to the date/time transforms. The logic then could be as follows:
function(x, force = FALSE, ...)
{
if (!inherits(x, "Date") & !force) {
stop("Invalid input: date_trans works with objects of class Date only",
call. = FALSE)
}
structure(as.numeric(x), names = names(x))
}
This would allow only the transformation of intentional numeric values while still raising the error upon unintentional input.
Thanks for reading!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancementhelp wanted ❤️we'd love your help!we'd love your help!