Skip to content
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

dplyr 1.1.0 compatibility #58

Merged
merged 2 commits into from
Dec 23, 2022
Merged

Conversation

DavisVaughan
Copy link
Contributor

This PR makes your package compatible with the next version of dplyr:

case_when() and if_else() now use vctrs, which generally makes them more permissive when there are varying types, but it resulted in two issues here:

  • case_when() can now only return vector types, which was the intention from the beginning. It was returning expressions in one of your use cases, but could easily be replaced with a switch()
  • The switch to vctrs resulted in surfacing this bug related to your na_of_type() function vec_ptype2(<character>, <character>)  r-lib/vctrs#1300. It is easier to just use x[NA_integer_] as a generic way to get the same thing in a way that vctrs is okay with. More importantly, in the dev version of dplyr you can just use NA so you won't need to worry about this at all after 1.1.0 is released! But for now we need the way I've done it to be compatible with dev and CRAN dplyr.

We plan to submit dplyr 1.1.0 on January 27th.

This should be compatible with both dev and CRAN dplyr. It would help us out if you could go ahead and send a patch version of your package in ahead of time! Thanks!

@nacnudus nacnudus merged commit 2cad303 into nacnudus:main Dec 23, 2022
@nacnudus
Copy link
Owner

Thanks for the patches and the explanations! I simplified it further to x[NA], which seems to work.

@DavisVaughan
Copy link
Contributor Author

There is a big difference between x[NA] and x[NA_integer_]. The first returns a missing vector the same size as the input, the second returns a size 1 missing vector.

x <- 1:5

x[NA]
#> [1] NA NA NA NA NA

x[NA_integer_]
#> [1] NA

Created on 2022-12-23 with reprex v2.0.2.9000

@nacnudus
Copy link
Owner

Thanks, it's fine either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants