1. เรียนรู้
  2. /
  3. Courses
  4. /
  5. Data Manipulation with data.table in R

Connected

Exercises

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.

คำแนะนำ 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.