-
Notifications
You must be signed in to change notification settings - Fork 28
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
Cannot Use ggplot2 with units #164
Comments
Was this working with the previous version of
That's not the problem, The cleanest solution is to provide a ScaleUnits, but this is already included in the |
I'm testing with ggplot2 version 2.2.1 (not 3.0). If ggforce fixes it, maybe we can do the following (not tested): scale_type.units <- function(x) {
if (require(ggforce)) {
ggforce::scale_type.units(x)
} else {
stop("Please install and load the ggforce library to plot units with ggplot2")
}
} |
One more note:
The issue that I was pointing to is that the output of |
Yes, sorry, I messed up my explanation: the output of that The thing is that the first argument determines which method is dispatched. The first argument is About |
Thanks for the clarification. I'll ask that the order in the call to |
Has this issue been resolved? |
Please, keep this open. This is low priority, because it's not a regression, but I would like to have a further look into this. |
The fix to |
@billdenney But anyway, I don't think that the error showed in your first message is acceptable. It should work ignoring units, but with a warning, or the error should point to |
Unfortunately, there's not much we can do here without moving |
There is a fix that made it into the scales package that hopefully addresses this. (r-lib/scales#167) |
Unfortunately, it doesn't. It avoids that error just to get into another one. |
Shucks. |
It works with It would be great if it worked out of the box with only units loaded. Perhaps borrow the implementation from ggforce, and adapt similarly to the pillar PR? |
Initially, here we were trying to point to ggforce if it wasn't loaded, but found no way. Instead, I suppose you mean porting ggforce's implementation here, guarding it behind a @thomasp85 How would you feel about moving |
Fine with me |
Thanks, @thomasp85. I can send you a PR with deprecation warnings after porting the functionality here if you wish. |
Please do 🙂 |
I just tried to plot data using ggplot2 with a units vector, and it yielded an error. Diving into the ggplot2 code, the issue comes down to
range(NULL, units_value)
returning a numeric vector which cannot be compared with aunits
class object. Specifically, this occurs in https://github.com/tidyverse/ggplot2/blob/8778b48b37d8b7e41c0f4f213031fb47810e70aa/R/range.r#L21-L25 which involves a call toscales::train_continuous
which has eitherNULL
or a numeric vector as the first argument torange
.I don't see a way to fix this without either converting the value I'm plotting to numeric (easy, but losing information and losing an opportunity to make a common pair of libraries more usable together) or converting the
units
library to an S4 class, but maybe you see a simpler way to do this?The text was updated successfully, but these errors were encountered: