Why we need ungroup function while grouping more than one variable in dplyr package?

r

#1

I am forming a data frame using dplyr package in R in which I am grouping data set by two variable .

grouping=group_by(pf,age,gender) #pf is the data set and age and gender are variable

Then I have created a data frame using dplyr package

pf.fc_by_age_gender=summarise(grouping,mean_friend_count=mean(friend_count),median_friend_count=median(friend_count),n())

I want to know why it is necessary to ungroup the data frame before arranging the data frame.


#2

I know it’s too late but this link may help you