Create lag / lead time series with by groups in Julia?
问题 I am wondering if there is an easy way to create a lag (or lead) of a time series variable in Julia according to a by group or condition? For example: I have a dataset of the following form julia> df1 = DataFrame(var1=["a","a","a","a","b","b","b","b"], var2=[0,1,2,3,0,1,2,3]) 8×2 DataFrame │ Row │ var1 │ var2 │ │ │ String │ Int64 │ ├─────┼────────┼───────┤ │ 1 │ a │ 0 │ │ 2 │ a │ 1 │ │ 3 │ a │ 2 │ │ 4 │ a │ 3 │ │ 5 │ b │ 0 │ │ 6 │ b │ 1 │ │ 7 │ b │ 2 │ │ 8 │ b │ 3 │ And I want to create a