I'm practicing dplyr package using famous dataset from ggplot2, 'diamonds' data. I am trying to calculate mean 'price' of diamonds grouped by variable 'cut'. My code is as following.
price.cut <- diamonds %>%
group_by(cut) %>%
summarize(Mean = mean(price, na.rm=TRUE))
My expectation is to get mean price grouped by 'cut' variable. However, I only get one value, the total mean of price.
>price.cut
Mean
1 3932.8
What am I doing wrong?