Hi i just tried to sun a simple exmaple which is given here
https://stackoverflow.com/questions/61038354/create-lag-lead-time-series-with-by-groups-in-julia
using DataFrames, ShiftedArrays
df1 = DataFrame(var1=["a","a","a","a","b","b","b","b"],
var2=[0,1,2,3,0,1,2,3]);
by(df1, :var1, var2_l2 = :var2 => Base.Fix2(lag, 2))
but it resulted in below error
julia> by(df1, :var1, var2_l2 = :var2 => Base.Fix2(lag, 2))
ERROR: UndefVarError: lag not defined
Stacktrace:
[1] top-level scope
@ ~/data/code/NICU_DEC_2022/data_wrangling.jl:105
Is there any other way to get lag and lead values of a column.
I used to use below code earler, but its not working now
transform!(groupby(df,:ID),:TIME => lag, :TIME => lead)
Thanks in advance