Skip to content

[FEAT] Support for per-operation grouping within fsummarise/fmutate akin to dplyr's .by argument #881

Open

Description

@wgrundlingh

What aspect of the package is your request related to?
dplyr introduced per-operation grouping support via a .by argument within functions like summarise and mutate in 2023 (dplyr 1.1.0), thereby avoiding explicit group_by() and ungroup() calls in a pipeline. A similar option for fsummarise and fmutate would be great!

Describe the solution you'd like
Instead of

<some pipeline> %>%
  fgroup_by(<group vars>) %>%
  fsummarise(<summary vars>) %>%
  fungroup() %>%
  <more pipeline>

allow for

<some pipeline> %>%
  fsummarise(
    .by = <group vars>,
    <summary vars>
  ) %>%
  <more pipeline>

and similarly for fmutate.

Additional context
This would allow for a virtual drop-in replacement of summarise or mutate functions into existing code, with much smaller pipeline modifications.

Activity

  1. SebKrantz commented on Sep 12, 2026

    @SebKrantz
    Member

    Hi @wgrundlingh. Thanks! I am not currently planning to implement this, as fgroup_by() grouping in collapse is really efficient, there are g arguments to the fast statistical functions which can be used, especially in fmutate() calls, and there is a convenience function for aggregation called collap(). Plese carefully read this vignette for recommended programming patterns and also see my answer to #674. I also note that the Claude Code Skill now provides expert guidance on collapse to agents.

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions