-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Adding scale_*_discrete() to date variable can crash R #1542
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
Here is the relevant change -- r-lib/scales@cd0395d |
Are you sure that's the change? It seems weird that a check in continuous scales would break discrete scales |
Yes, it appears both > scale_x_discrete
function (..., expand = waiver())
{
sc <- discrete_scale(c("x", "xmin", "xmax", "xend"), "position_d",
identity, ..., expand = expand, guide = "none")
sc$super <- ScaleDiscretePosition
class(sc) <- class(ScaleDiscretePosition)
sc$range_c <- continuous_range()
sc
} Just to demonstrate that the change I refer to above is relevant, you can install r-lib/scales#70 to see that the example now throws an error. |
Ah, that makes sense. But I'd rather fix it by handing the poor performance with many levels |
Hmmm, something is seriously messed up with code that handles the combination of discrete and continuous ranges. I need to think through exactly how this should behave - the reason why discrete scale also have a continuous component is so that this sort of plot can work: ggplot(mtcars, aes(factor(cyl), mpg)) + geom_jitter() |
With scales 0.3, this code will error:
Running this code using the latest dev version of scales doesn't result in error, and ggplot tries to draw a plot with 1e4 ticks. I know this is a cornercase, but I would prefer an error since it can easily wreak havoc on an R session, especially with date-times.
The text was updated successfully, but these errors were encountered: