I'm having problem with this 'textbook' example on how to aggreate data by group:
library(dplyr)
iris %>% group_by(Species) %>% summarise(sum(Sepal.Length))
I'm getting different results on diffent R/Rstudio sessions on the same computer.
Session A: the above code returns a one line output:
sum(Sepal.Length)
1 876.5
Session B: same code returns the expected output:
Species sum(Sepal.Length)
1 setosa 250.3
2 versicolor 296.8
3 virginica 329.4
In session A I had open some other dataset and libraries before. However I made sure I executed library(dplyr) imediattely before the group_by()%>%summarise()
What on earth can be happening?
EDIT: based on comments bellow, I double checked, and, yes: I'm calling library(plyr) before library(dplyr). And yes, the suggestion library(dplyr) iris %>% group_by(Species) %>% summarise(sum(Sepal.Length))