What is Ungroup() in R programming?

Ungroup() function in R programming is used in data management. It is used to ungroup the data from its grouped form. It is always used after the group() function. But remember to always use ungroup() function after the execution of code.




There are no parameters.

Return value

The grouped data as ungroup form.


#Given data is grouped here
#Calculates the average age of boys and girls
#mutate() function is used to add columns in given data
mutate(boys = mean(age)) 
#get mean score
mutate(x = mean(score))  
#Close the group
  • Line#2: it will group the data by gender.
  • Line#6: Using mutate() method to get the mean of the age of boys in the data.
  • Line#8: It’ll return the mean score of students.
  • Line#10: Using the ungroup() function to ungroup the data.

Stay in the Loop

Get the daily email from Algoideas that makes reading the news actually enjoyable. Join our mailing list to stay in the loop to stay informed, for free.

Latest stories

- Advertisement -

You might also like...