I want the previous row value for different groups. I have gone through the solution given here and also tried the code shown below.
new_data[,avg_week := shift(.(avg_travel_time),type = "lag"), by = identifier]
This is the error that I am getting.
Error in `[.data.frame`(new_data, , `:=`(avg_week, c(NA, avg_travel_time[-.N])), :
unused argument (by = identifier)