Model answer & my answer failed on R studio

Screen Link:

My Code:

class_size<-class_size%>%group_by(CSD,`SCHOOL CODE`, `SCHOOL NAME`)%>% summarize(avg_class_size=mean(`AVERAGE CLASS SIZE`), avg_largest_class=mean(`SIZE OF LARGEST CLASS`),avg_smallest_class=mean(`SIZE OF SMALLEST CLASS`))

What I expected to happen:
I don’t understand what the output means. My answer is the same as the model answer, and when i tried out the model answer & my own code on R studio, both returned the same output, and the same issues. I’m not sure how to go about this part of the exercise.

What actually happened:

`summarise()` regrouping output by 'CSD', 'SCHOOL CODE' (override with `.groups` argument)

1 Like

Hi There.

The message you are getting is perfectly normal. It is not an error. If you use ‘summarize’ on a grouped dataframe it removes one grouping level automatically (the lowest). In your case in essence going from the dataframe being grouped by:


to being grouped by:


What R is telling you in addition is that you could override this by explicitely using the .groups argument when calling the summarise function. In most beginner scenarios this is probably not necessary.


Hi! Thanks for your reply, but I’m still unsure why my answer, same as the model answer is wrong?

1 Like