A simpler approach is to define a lag function that respects time gaps, and then use transform to apply this function within groups. Comment this PR if you are interested: https://github.com/JuliaArrays/ShiftedArrays.jl/pull/37
1 Like