79442391

Date: 2025-02-15 23:45:14
Score: 0.5
Natty:
Report link

Using collapse::flag. Lagged columns are automatically renamed with a prefix.

d = data.frame(t = 1:6)

library(collapse)
flag(d, n = 0:2)
#   t L1.t L2.t
# 1 1   NA   NA
# 2 2    1   NA
# 3 3    2    1
# 4 4    3    2
# 5 5    4    3
# 6 6    5    4
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Gusbourne