tscslag | R Documentation |
Lags (or leads) a variable in a time-series corss-sectional dataset.
tscslag(dat, x, id, time, lagLength = 1)
dat |
A data frame. |
x |
A string identifying variable to be lagged. |
id |
A string identifying the name of the cross-sectional identifier. |
time |
A string identifying the name of the time variable. |
lagLength |
The length of the lag, use negative values for leading variables. |
A vector giving the lagged values of x
.
Dave Armstrong
data(aclp)
aclp$lag_gdpw <- tscslag(aclp, "gdpw", "country", "year")
head(aclp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.