-
Notifications
You must be signed in to change notification settings - Fork 2.1k
facet_wrap() and facet_grid() with a date variable is broken #3313
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
Comments
@yutannihilation Do you have time to look into this issue? |
Sure, will do. |
Quickly confirmed #3327 fixes this issue. Sorry, I'm afraid I won't be very responsive until the end of this month... |
I would be happy to PR a test for this if that is helpful. |
I don’t think it makes sense to test for some arbitrary ordering as long as we don’t break something in revdeps... we will probably have to actively break this once we move to rbinding through vctrs at is is unlikely to follow the arbitrary rules of plyr, but it is best to break only once |
Though ordering is just an implementational detail, I think it makes sense to ensure facetting by Date is not broken. |
I’m simply weary because the old ordering (which is now replicated) is logically wrong. Setting up a unit test may give it some undeserved credibility |
Yeah, I agree that we don't need a test about ordering, but the one about facetting by Date (probably it would not be a unit test). |
(But, since I don't have enough time to help right now and it seems not necessary for the release, please ignore my comments. Sorry...) |
I accidentally closed this from a typo in PR 3331...can I/should I fix this? |
BTW, what about library(ggplot2)
packageDescription("ggplot2")[c("GithubRef", "GithubSHA1")]
#> $GithubRef
#> [1] "plyr-order"
#>
#> $GithubSHA1
#> [1] "b078f6901cc66968a04587585015559a42f71087"
df <- data.frame(date = as.Date("2019-01-01"), x = 1, y = 1)
df$date <- as.POSIXct(df$date)
p <- ggplot(df, aes(x, y)) + geom_point()
p + facet_grid(vars(date))
#> Error in scale_apply(layer_data, x_vars, "train", SCALE_X, x_scales): |
I've fixed |
Oh, thanks for fixing! |
closed by #3327 |
This issue appears to occur still with POSIXct variables, but not with Dates - see attached sample data and below code. outlierSummary$week2 <- as.Date(outlierSummary$week, format = "%Y-%m-%d") obc=ggplot(data=outlierSummary,aes(x=type,y=outpc,fill=type))+geom_bar(stat = "identity")+ #With posixct #With Date |
Could you open a new issue with a more minimal example? It saves us quite a bit of time if we can copy and paste a small section of code to recreate the error. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
The revdeps (#3303) identified that using
facet_grid()
orfacet_wrap()
with a date variable is broken. This probably affects other S3 vectors as well.The error is in
Facet(Grid|Wrap)$map_data()
, where there is a join between the layout and the panels. In one of these,date
is a factor, and in the other, it is an S3Date
. This changed because of different behaviour betweenjoin_keys()
and its previous plyr counterpart.The text was updated successfully, but these errors were encountered: