Skip to content

Add [ method for grouped_df #4708

@hadley

Description

@hadley
`[.grouped_df` <- function(x, i, j, drop = FALSE) {
   out <- NextMethod()
   groups <- intersect(names(out), dplyr::group_vars(x))

   if (length(groups)) {
     dplyr::grouped_df(out, groups)
   } else {
     dplyr::tbl_df(out)
   }
 }

Related to #4004

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions