Sorry, this is what I used :
f <- function(x) {
wage <- ts(x$wage, start = x$year[1])
idx <- seq(length = length(wage))
wages <- cbind(wage, wage.lag1 = lag(wage, -1))[idx,]
cbind(x, wages)
}
result <- do.call("rbin
On Wed, Aug 29, 2012 at 8:20 PM, Alok Bohara, PhD wrote:
> Thanks for the input. I wanted to avoid counting the column number. In
> any case, in the script -- wage.lag1 = lag(wage, -1) seems to do the trick.
The important thing is that "4" in my example below can be any
computable expression:
Thanks for the input. I wanted to avoid counting the column number.
In any case, in the script -- wage.lag1 = lag(wage, -1) seems to do the
trick.
Alok
On 8/29/2012 12:29 PM, R. Michael Weylandt
wrote:
Of course:
colnames(dats)[4] <- "new name"
M
On Aug 29, 2012, at 9:34 AM, "Alok K
HI,
Try this:
wage2.dat<-read.table(text="
year person wage lag(wage,-1)
1980 1 -0.75843997 NA
1981 1 0.27233048 -0.75843997
1982 1 -1.58335767 0.27233048
1983 1 0.36805926 -1.58335767
1984 1 -0.52312153 0.36805926
1980 2 -0.
Of course:
colnames(dats)[4] <- "new name"
M
On Aug 29, 2012, at 9:34 AM, "Alok K Bohara, PhD" wrote:
> 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 pers
5 matches
Mail list logo