How to reshape wide to long?

try this


dfs=stack(df,2:7)

dfp1=select(dfs,[1,3],:variable=>ByRow(x->(x[1:3], x[4:7]))=>[:t,:year])
unstack(dfp1,[:id,:year],:t,:value)

PS
In hindsight, this seems, for the case in question, to be the canonical way of proceeding

2 Likes