Skip to content

group_indices.data.frame() should use .drop = TRUE by default? #4208

Closed

Description

@yutannihilation

Related: tidyverse/tidyr#555 (comment)

I think this .drop, which is passed to group_by(), should be TRUE or group_drops(.data) (which should return TRUE for data.frame) by default.

group_indices.data.frame <- function(.data, ..., .drop = FALSE) {

tidyverse/tidyr#555 (comment) might be a tidyr's fault in that it should not expect the group indices are always consecutive integers. But, I feel the behaviour below is inconsistent and should be fixed.

library(dplyr, warn.conflicts = FALSE)

d <- tibble(x = letters[1:10], y = rep(1:2, each = 5), z = factor(rep(LETTERS[1:2], each = 5)))

d %>% 
  group_by(y, z) %>%
  group_indices()
#>  [1] 1 1 1 1 1 2 2 2 2 2

d %>% 
  group_indices(y, z)
#>  [1] 1 1 1 1 1 4 4 4 4 4

Created on 2019-02-21 by the reprex package (v0.2.1.9000)

Activity

  1. romainfrancois commented on Feb 21, 2019

    @romainfrancois
    Member

    indeed, can you send a pull request please ?

  2. yutannihilation commented on Feb 21, 2019

    @yutannihilation
    MemberAuthor

    Sure!

  3. lock commented on Aug 20, 2019

    @lock

    This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

  4. locked and limited conversation to collaborators on Aug 20, 2019
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