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_by() + mutate() does not preserve row order #14

Closed
nathaneastwood opened this issue May 3, 2020 · 0 comments
Closed

group_by() + mutate() does not preserve row order #14

nathaneastwood opened this issue May 3, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@nathaneastwood
Copy link
Owner

For example

r$> data <- data.frame(a = c(0, 1, 0, 1, 0, 1), b = rnorm(6))                                                                                            

r$> data                                                                                                                                                 
  a          b
1 0  0.1975196
2 1 -0.9084617
3 0 -1.1766728
4 1 -2.3127030
5 0 -0.7029450
6 1 -2.2935241

r$> data %>% group_by(a) %>% mutate(b2 = b * 2)                                                                                                          
  a          b         b2
1 0  0.1975196  0.3950392
3 0 -1.1766728 -2.3533457
5 0 -0.7029450 -1.4058900
2 1 -0.9084617 -1.8169233
4 1 -2.3127030 -4.6254060
6 1 -2.2935241 -4.5870483

Groups:  a 
@nathaneastwood nathaneastwood added the bug Something isn't working label May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant