Do in data.table what The data.table Format teaches: DT[i, j, by].

The program reads the name of a column to group by: gear, cyl or am.

  1. Convert mtcars to a data.table with as.data.table().
  2. For each group, compute the number of cars (.N) and the mean mpg rounded to 1 decimal place. Call the columns cars and mpg.
  3. Sort by the grouping column and print the result.

Hint: by = group_col works when group_col holds a column name as text, and setorderv(result, group_col) sorts by it.

You do not have permission to attempt this activity.