Re: [R] Lag variable by group

2015-09-08 Thread Janka VANSCHOENWINKEL
nwin...@uhasselt.be] > *Sent:* Tuesday, September 08, 2015 8:48 AM > *To:* PIKAL Petr > *Cc:* r-help@r-project.org > *Subject:* Re: [R] Lag variable by group > > > > Hi Petr and other member who can use this post, > > > > Somebody gave me an answer in a privat

Re: [R] Lag variable by group

2015-09-07 Thread Janka VANSCHOENWINKEL
quot;28955", > "28956", "28957", "28958", "28959")) > > But now I am lost what result you expect. Can you explain it on this > smaller data set? > > Cheers > Petr > > > -Original Message- > > From: R-help [mailto:

Re: [R] Lag variable by group

2015-09-07 Thread PIKAL Petr
t;, "28957", "28958", "28959")) But now I am lost what result you expect. Can you explain it on this smaller data set? Cheers Petr > -Original Message- > From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Janka > VANSCHOENWINKEL > Se

[R] Lag variable by group

2015-09-07 Thread Janka VANSCHOENWINKEL
Hi! I have the following dataset with the variables ID (this is a unique ID per farmer), year, and another variable t1. I now would like to have a fourth variable which is the lag value of t1 for each farm ID. I found a code on the internet that does exactly what I need, but it does not work for