Skip to content
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

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

Closed
yutannihilation opened this issue Feb 21, 2019 · 3 comments
Closed

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

yutannihilation opened this issue Feb 21, 2019 · 3 comments

Comments

@yutannihilation
Copy link
Member

@yutannihilation yutannihilation commented Feb 21, 2019

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)

@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Feb 21, 2019

indeed, can you send a pull request please ?

@yutannihilation
Copy link
Member Author

@yutannihilation yutannihilation commented Feb 21, 2019

Sure!

@lock
Copy link

@lock lock bot commented Aug 20, 2019

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/

@lock lock bot locked and limited conversation to collaborators Aug 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants