Skip to content

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

Closed

Description

@DavisVaughan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions