Computing stats by groups (I)
So far you have worked with the two dimensions, rows and columns of a data.table
. It's now time to consider the virtual third dimension by dividing rows into groups to calculate statistics.
This exercise is part of the course
Data Manipulation with data.table in R
Exercise instructions
Compute the mean duration for every start_station
, calling the aggregated column mean_duration
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Compute the mean duration for every start_station
mean_start_stn <- batrips[, .(___), by = ___]
mean_start_stn