-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Rewrite nth()
, first()
, and last()
using vctrs
#6331
Conversation
This one might actually be too extreme. It seems like a lot of people use 14 broken revdeps:
See #6262 for details We might be able to make it use
It depends on how strongly we feel about the invariants of these functions (i.e. should they always return an object the same type as I guess |
Worth incorporating #6257? |
I thought about it but I think it'll be easier to me to keep it straight if I do that in a separate PR This one is ready for review now though |
Because using `vec_slice()` breaks too many revdeps that use these functions on lists and expect to get list elements back
3d30660
to
839d494
Compare
Compatibility with tidyverse/dplyr#6331
Revival of #4636
Technically closes tidyverse/funs#35
I am now quite confident that
first()
and friends should use[
/vec_slice()
rather than[[
/vec_get()
. I think the invariant for these functions should be that they return an object with:x
This guarantees they will be useful with
summarise()
, which is good because?summarise
already mentions them as "Useful Functions"This change mainly affects lists, which now return a list of size 1 rather than the actual element of the list. But I think that change is correct - i.e. it feels weird for "first" to return something that could be size >1. It also affects data frames, which previously returned a single column but now return a single row (which again, feels more consistent).
I'll check revdeps to ensure this doesn't cause a big uproar, but I think these are relatively uncommon edge cases
"252be158-3a4a-4e70-a233-4a9a0a858637"