Re: [R] Taking a lead in panel data

2012-05-10 Thread Apoorva Gupta
I have tried the diff and lag function. I have given an example below. Diff gives me a$var2.shift. I want a$var2.noshift, i.e. var^(t+2)-var^(t) should stay in the row with year=t. Diff shifts it to the t+2 row. > a <- data.frame(c(rep(2,5), rep(3,5)), c(2005:2009, 2004:2008), c(NA,10,34,23,12, 2

Re: [R] Taking a lead in panel data

2012-05-08 Thread Liviu Andronic
On Tue, May 8, 2012 at 12:14 PM, Apoorva Gupta wrote: > I have checked that. It allows me to get the t-1, t-2 value but not the t+1 > value. > Is there any other way of achieving this other than using the plm package? > It would be easier to help if you provided a minimal reproducible example, as

Re: [R] Taking a lead in panel data

2012-05-08 Thread Apoorva Gupta
I have checked that. It allows me to get the t-1, t-2 value but not the t+1 value. Is there any other way of achieving this other than using the plm package? On Mon, May 7, 2012 at 8:27 PM, Liviu Andronic wrote: > On Mon, May 7, 2012 at 3:21 PM, Apoorva Gupta > wrote: > > Dear R users, > > I am

Re: [R] Taking a lead in panel data

2012-05-07 Thread Liviu Andronic
On Mon, May 7, 2012 at 3:21 PM, Apoorva Gupta wrote: > Dear R users, > I am working with panel data and I want the difference of a variable with > its t+1 value. > > Could you tell me if such a function exists in the plm package? > Perhaps diff() or lag(). See the plm vignette. Liviu _

[R] Taking a lead in panel data

2012-05-07 Thread Apoorva Gupta
Dear R users, I am working with panel data and I want the difference of a variable with its t+1 value. For example, I have a data frame as below. > a <- data.frame(c(rep(2,5), rep(3,5)), c(2005:2009, 2004:2008), c(NA,10,34,23,12, 23,45, NA, 45, NA)) > colnames(a) <- c("firm","year","var") I want