1. Learn
  2. /
  3. Courses
  4. /
  5. Data Manipulation with data.table in R

Connected

Exercise

Updating columns by group

You often need to create new intermediate columns to get to the final result but don't necessarily need these intermediate columns in the final result. This is a very common pattern in data analysis.

In this exercise, you will work with a new data.table, batrips_new, which is almost identical to batrips, except we randomly introduced some missing values in the duration column.

Instructions 1/3

undefined XP
    1
    2
    3

Add a new column (mean_dur) by reference that is the mean duration of all trips grouped by month (based on start_date). Note that the duration column has missing values.