I have checked the group_by function to select mean disp of one cylinder type in mtcars, but it's not giving me the right answer. See below;
summarise(group_by(mtcars,cyl), mean(disp))
Output:
> summarise(group_by(mtcars,cyl), mean(disp))
# A tibble: 3 x 2
cyl `mean(disp)`
<dbl> <dbl>
1 4 105.
2 6 183.
3 8 353.
But
summarise(group_by(mtcars,cyl = 6), mean(disp))
Output:
> summarise(group_by(mtcars,cyl = 6), mean(disp))
# A tibble: 1 x 2
cyl `mean(disp)`
<dbl> <dbl>
1 6 231.
Note: I wanted to get the same answer for cylinder type 6 as per the first code. But the answers are different.