Last chance! 50% off unlimited learning
Sale ends in
lagdata
creates single lagged and moving average variables of the lag number that the user designate.
lagdata(data, varlist, laglength)
lagdata
gives single lagged variables (varname_sxx, xx indicates lag length) and moving average variables (varname_mxx).
# read the data
data(mort)
seoul = read6city(mort, 11)
# create lagged and moving average variables
seoul_lag = lagdata(seoul, c("meantemp", "mintemp", "meanpm10", "meanhumi"), 5)
Run the code above in your browser using DataLab