-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Let check_nondata_cols allow Vector class (#3835) #3837
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
Conversation
The However, it would be good to get input from @thomasp85 and/or @yutannihilation. There may be something I'm missing. |
I've meanwhile managed to also run the tests with the sf package, which don't seem to be affected. |
Sounds good to me! I've been wondering how we can replace |
I might not be particularly aware what function the print(tibble:::is_1d_or_2d) # is a check in tibble:::check_valid_cols
#> function (x)
#> {
#> (is_vector(x) && !needs_dim(x)) || is.data.frame(x) || is.matrix(x)
#> }
#> <bytecode: 0x4272488>
#> <environment: namespace:tibble> I tried to explore what behaviour would be different if we'd remove the
The above would throw an error with Also the following case:
Returns this error with
And this error without
I think the matrix case is actually kind of convenient and the error messages about POSIXlt are both indicating what class is causing trouble. Would it be acceptable to remove the |
Let's assess the need for Lines 120 to 124 in 660aad2
Second in Lines 265 to 268 in 660aad2
I think the Lines 237 to 246 in 660aad2
Am I missing a use of this function? @thomasp85 Do you want to chime in? You wrote the |
While we're at it, I also found this, which is essentially equivalent to a call to Lines 420 to 423 in 660aad2
|
Thank you very much Claus for assessing I'm going to go ahead with removing the |
Yes, this looks good to me. I think the code in facet-.r needs to be handled separately, since we'd probably want an input check there. |
@thomasp85 Unless you have strong objections, I'd say let's go ahead with this. It seems the worst case scenario is a less informative error message in some strange corner case, and if that arises we can deal with it then. |
Don't we need a NEWS bullet for this? |
I guess a news item would be good, so people are more broadly aware that this now works. @teunbrand Could you add a 1-2 sentence news item in |
Merge in current master
Sure thing. I didn't know how to do that without merging in the current master first, but I hope it is correct. Thanks everyone for the help! |
Merging in the current master is correct. However, I'd like to ask you to rephrase the news item. Usually we try to not focus on the technical details but instead write something that makes sense to the user. So in this case, I think it should be something like "ggplot2 now accepts data columns of type |
Yes that indeed sounds more informative. Thanks! |
Thanks! |
Let check_nondata_cols allow Vector class (tidyverse#3835) (tidyverse#3837)
This PR comes from the discussion over at #3835.
The change in code does only one thing: it add
inherits(x, "Vector")
to the allowed data columns check.This would allow a large number of classes that exhibit vector-like behaviour from Bioconductor to be valid data columns.
I was experimenting around with this, and realised that this PR is necessary but not sufficient to let the S4 classes reach the scale transforming stage of plot building. I'd like to reach that stage of plot building since the scales are extendable and I can work with the S4 classes from there onwards.
What I would additionally like is to drop/replace the
as_tibble()
inas_gg_data_frame()
since it also throws errors with S4 classes. Relevant code here:ggplot2/R/utilities.r
Lines 379 to 393 in 53edc51
I ran the unit tests with the code changed from
new_data_frame(tibble::as_tibble(x))
tonew_data_frame(x)
and this both didn't seem to break any tests and seemed sufficient for the S4 classes to reach the scales. Disclaimer: I couldn't install the sf package, so these tests were skipped. Relevant issues to consider should be #2609 and #2374.Thanks for reading and considering!