Skip to content

Can we somehow have nest(.by = )? #1458

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

Closed
DavisVaughan opened this issue Jan 10, 2023 · 0 comments · Fixed by #1461
Closed

Can we somehow have nest(.by = )? #1458

DavisVaughan opened this issue Jan 10, 2023 · 0 comments · Fixed by #1461

Comments

@DavisVaughan
Copy link
Member

DavisVaughan commented Jan 10, 2023

dplyr::nest_by(data, x, y) is somewhat useful because I like that the variables you specify are the ones that end up outside the nesting. The equivalent nest(data, -c(x, y)) has always felt very awkward to me.

But really we'd like to pick one of nest(), nest_by() and group_nest() and deprecate the others.

It feels like tidyr is the right place for nest() to live, but it would be nice if we could somehow bring that by behavior over.

Maybe it is something like nest(.data, ..., .by = NULL/everything())? Then you could do nest(data, .by = c(x, y)) to get the nest_by() behavior. I still think you could use the ... in combination with .by, we'd just have to think about exactly how that would work (and can you duplicate variables in both .by and ...?)

We'd have to consider if this conflicts with the current behavior of nest(data) with no ..., which currently nests everything (rather than nothing, as might be expected by nest(data, .by = c(x, y)))

Consider how this conflicts with dplyr .by, and if that would be confusing or not. It might not be, because they seem to be very similar concepts.

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 a pull request may close this issue.

1 participant