Group by Rows

Learn how to group together rows and create new meaningful analysis.

Example with the temperature dataset

Instead of a single mean temperature for the whole year, we would like 12 mean temperatures, one for each of the 12 months separately. In other words, we would like to compute the mean temperature split by month. We can do this by grouping temperature observations by the values of another variable, and in this case, by the 12 values of the variable month. Run the following code:

Get hands-on with 1200+ tech skills courses.