I've recently started utilizing the dplyr package for data manipulation but don't have a complete grasp on the output of group_by(). In the example below how can my single iris.2 object have 4 different classes? How does the function know which class to use? IE if I call print it will call the print.tbl_df method and not the print.data.frame.
library(dplyr)
iris.1 <- iris
iris.2 <- group_by(iris, Species)
class(iris.1)
[1] "data.frame"
class(iris.2)
[1] "grouped_df" "tbl_df" "tbl" "data.frame"