Re: [R] Counting occurrences in a moving window

2011-06-03 Thread mdvaan
Thank you very much! I really liked the first solution, it worked great for my larger dataset. M Gabor Grothendieck wrote: > > On Fri, Jun 3, 2011 at 8:11 AM, mdvaan > wrote: >> Would it be possible to use the sqldf package and the ave function to >> simply >> run ave

Re: [R] Counting occurrences in a moving window

2011-06-03 Thread Gabor Grothendieck
On Fri, Jun 3, 2011 at 8:11 AM, mdvaan wrote: > Would it be possible to use the sqldf package and the ave function to simply > run ave over a limited set? So something like: > > DF = data.frame(read.table(textConnection("  A  B > 8025  1995 > 8026  1995 > 8029  1995 > 8026  1996 > 8025  1997 > 802

Re: [R] Counting occurrences in a moving window

2011-06-03 Thread Gabor Grothendieck
On Thu, Jun 2, 2011 at 11:41 AM, mdvaan wrote: > Hi list, based on the following data.frame I would like to create a variable > that indicates the number of occurrences of A in the 3 years prior to the > current year: > > DF = data.frame(read.table(textConnection("  A  B > 8025  1995 > 8026  1995

Re: [R] Counting occurrences in a moving window

2011-06-03 Thread mdvaan
Would it be possible to use the sqldf package and the ave function to simply run ave over a limited set? So something like: DF = data.frame(read.table(textConnection(" A B 8025 1995 8026 1995 8029 1995 8026 1996 8025 1997 8026 1997 8025 1997 8027 1997 8026 1999 8027 1999 802

[R] Counting occurrences in a moving window

2011-06-02 Thread mdvaan
Hi list, based on the following data.frame I would like to create a variable that indicates the number of occurrences of A in the 3 years prior to the current year: DF = data.frame(read.table(textConnection(" A B 8025 1995 8026 1995 8029 1995 8026 1996 8025 1997 8026 1997 8025 1997 8027