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

mutate() loses groups #17

Closed
hadley opened this issue Mar 8, 2016 · 1 comment
Closed

mutate() loses groups #17

hadley opened this issue Mar 8, 2016 · 1 comment

Comments

@hadley
Copy link
Member

hadley commented Mar 8, 2016

Moved from tidyverse/dplyr#919, by kykuo

library(dplyr)
library(dtplyr)

iris %>%
  group_by(Species) %>% 
  mutate(x = cumsum(Sepal.Length)) %>% 
  groups

data.table::data.table(iris) %>% 
  group_by(Species) %>%
  mutate(x = cumsum(Sepal.Length)) %>%
  groups
@HuangNa2
Copy link

HuangNa2 commented May 3, 2017

Seems like mutate reduces the group by 1 everytime its called

library(dplyr)
library(dtplyr)

iris %>%
  group_by(Species,Petal.Width,Sepal.Length) %>% 
  mutate(x = cumsum(Sepal.Length)) %>% 
  groups

Results in :

[[1]]
Species

[[2]]
Petal.Width

From a bit of testing it appears that it removes the last grouped element each time mutate is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants