Hi R-helpers I want a function that performs the opposite of lag() with panel data. I have transformed my data before with pdata.frame(mydata, index=c("groupindex", “timeindex")) And then I’ve done lag(mydata, -1) but it doesn’t work. The error message was: Error in rep(1, ak) : invalid ''times'' argument Thank you in advance, Cecília Carmo [[alternative HTML version deleted]]
Is there perhaps a particular package you are interested in here? I'm not aware of a "pdata.frame" function... This certainly works with the xts class. If you just mean a regular data.frame() perhaps some of the ideas in this old thread will work with a little tweaking: http://www.mail-archive.com/r-help@r-project.org/msg142805.html Michael Weylandt On Thu, Sep 22, 2011 at 10:36 AM, Cecilia Carmo <cecilia.carmo@ua.pt> wrote:> Hi R-helpers > > > > I want a function that performs the opposite of lag() with panel data. > > I have transformed my data before with pdata.frame(mydata, > index=c("groupindex", “timeindex")) > > And then I’ve done lag(mydata, -1) but it doesn’t work. > > > > The error message was: > > Error in rep(1, ak) : invalid 'times' argument > > > > Thank you in advance, > > > > Cecília Carmo > > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >[[alternative HTML version deleted]]
Yes, I want to it with plm package for panel data in dataframes. Thank you, Cecília Carmo De: R. Michael Weylandt [mailto:michael.weylandt@gmail.com] Enviada: quinta-feira, 22 de Setembro de 2011 16:06 Para: Cecilia Carmo Cc: r-help@r-project.org Assunto: Re: [R] the opposite of lag() in panel data Is there perhaps a particular package you are interested in here? I''m not aware of a "pdata.frame" function... This certainly works with the xts class. If you just mean a regular data.frame() perhaps some of the ideas in this old thread will work with a little tweaking: http://www.mail-archive.com/r-help@r-project.org/msg142805.html Michael Weylandt On Thu, Sep 22, 2011 at 10:36 AM, Cecilia Carmo <cecilia.carmo@ua.pt> wrote: Hi R-helpers I want a function that performs the opposite of lag() with panel data. I have transformed my data before with pdata.frame(mydata, index=c("groupindex", “timeindex")) And then I’ve done lag(mydata, -1) but it doesn’t work. The error message was: Error in rep(1, ak) : invalid ''times'' argument Thank you in advance, Cecília Carmo [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]