[R] creating lagged variable in panel data

Alok K Bohara, PhD bohara at unm.edu
Wed Aug 29 16:34:51 CEST 2012


Hi

I found an example in R to create a lagged panel data set which works 
fine.  The only problem is that it adds the lagged variable as follows

wage2.dat

           year person        wage        lag(wage, -1)
1.1  1980      1 -0.75843997            NA
1.2  1981      1  0.27233048   -0.75843997
1.3  1982      1 -1.58335767    0.27233048
1.4  1983      1  0.36805926   -1.58335767
1.5  1984      1 -0.52312153    0.36805926
2.6  1980      2 -0.53559110            NA
2.7  1981      2 -0.94935350   -0.53559110
2.8  1982      2  0.10486688   -0.94935350
2.9  1983      2 -0.50266443    0.10486688
2.10 1984      2  0.14644024   -0.50266443
.
.

Is there anyway  I could rename the last column      wag.lag1? Thanks.


Best,
Alok



More information about the R-help mailing list