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
Setting .keep = "used" in mutate() is the only settings for this argument that induces the drop of the grouping in both devel and CRAN versions.
.keep = "used"
library(dplyr, warn.conflicts = FALSE) iris %>% group_by(Species) %>% mutate(meanPL = mean(Petal.Length), .keep = "none") #> # A tibble: 150 x 2 #> # Groups: Species [3] #> Species meanPL #> <fct> <dbl> #> 1 setosa 1.46 #> 2 setosa 1.46 #> 3 setosa 1.46 #> 4 setosa 1.46 #> 5 setosa 1.46 #> 6 setosa 1.46 #> 7 setosa 1.46 #> 8 setosa 1.46 #> 9 setosa 1.46 #> 10 setosa 1.46 #> # … with 140 more rows iris %>% group_by(Species) %>% mutate(meanPL = mean(Petal.Length), .keep = "used") #> # A tibble: 150 x 2 #> Petal.Length meanPL #> <dbl> <dbl> #> 1 1.4 1.46 #> 2 1.4 1.46 #> 3 1.3 1.46 #> 4 1.5 1.46 #> 5 1.4 1.46 #> 6 1.7 1.46 #> 7 1.4 1.46 #> 8 1.5 1.46 #> 9 1.4 1.46 #> 10 1.5 1.46 #> # … with 140 more rows packageVersion("dplyr") #> [1] '1.0.2.9000'
Created on 2020-11-01 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered:
mutate() always keeps grouping variables, unconditional to .keep=
mutate()
.keep=
c2ece16
closes #5582
df43c73
No branches or pull requests
Setting
.keep = "used"
in mutate() is the only settings for this argument that induces the drop of the grouping in both devel and CRAN versions.Created on 2020-11-01 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: