Exercise

Adding columns by group

Recall that you can perform computations by group using the by argument of the data.table. In this exercise, you will add new columns by group to the original data.table by reference.

Instructions 1/2

undefined XP
  • 1

    Add a new column by reference called trips_N that is equal to the total number of trips for every start_station.

  • 2

    Add a new column by reference called duration_mean that is equal to the mean duration of trips for each unique combination of start_station and end_station.