I want to calculate a new row (difference_mean_by_worker_id) with the mean (difference) by one argument (worker_id) in my existing data frame. The mean of the difference of every single worker_id should be the same in the new row. Like this:
Thanks, Tim
Here is a
data.table
solution:This script calculates the mean for the distances in a group partitioned by
worker_id
. Hope this helps!