While direct method is no doubt efficient, if you are coming from an SQL world, you probably want to use something like ShiftedArrays.jl which has lag
and lead
functions: ANN: ShiftedArrays and support for ShiftedArrays in GroupedErrors
2 Likes