Hi I am new in R.
I am studing Econometric, Topic : Autocorrelation.
I created the regression, and I used the function residuals to create the residuals data.

regresion<-lm(Y~X, data=datos)
datos$residuals<-residuals(regresion)
Now I wanted to run the regression
Ut= residuals
regresion2<-ut~ ut-1+ut-2

My question is : Is there any way to create the data Ut-1 or Ut-2 (Lagging securities) in R Studios.
Many Thanks