Displaying 1 result from an estimated 1 matches for "nolag".
Did you mean:
nolan
2004 Oct 29
2
lag variable addition to data frame question
...9;, i want to create #lagged variables #of this without using as.ts(). Is #there a more effient way of doing this than#below and #without using a recursive loop such as
#for( i in 1:obs)x.lag[i]= x[(i-1)]
1.here is the way i am doing the lag now
x=c(3,2,3,2,1,1,1,2,1,2,1,3...1)
obs=length(x)
x.nolag=x[2:obs]
x.lag1=x[1:(obs-1)]
my.new=cbind(x.nolag,x.lag1)
#since my data frame must line up my orginal x values to other columns I also # add the following
x.fill= cbind(0,0)
# as named the above cell lines up my factor to other factors in my data frame, #since I had chopped off the first x obs...