Count number of records and generate row number within each group in a data.table April 1, 2023 by Tarik