Re: [R] moving average on irregular time series

2010-06-04 Thread Gabor Grothendieck
On Thu, Jun 3, 2010 at 8:04 PM, Gabor Grothendieck wrote: > Replace the non-events with NA and then use na.locf from the zoo > package to move the last event date up to give lastEvent. > Then simply select those rows whose lastEvent date is at least 14 days > ago or if the row itself is an Event:

Re: [R] moving average on irregular time series

2010-06-04 Thread Gustaf Rydevik
Dear William and Gabor, Both solutions worked, and my problem is now solved. Many thanks to both of you! regards, Gustaf > > On Thu, Jun 3, 2010 at 10:23 AM, Gustaf Rydevik > wrote: >> Hi all, >> >> >> I wonder if there is any way to calculate a moving average on an >> irregular time series,

Re: [R] moving average on irregular time series

2010-06-03 Thread Gabor Grothendieck
Replace the non-events with NA and then use na.locf from the zoo package to move the last event date up to give lastEvent. Then simply select those rows whose lastEvent date is at least 14 days ago or if the row itself is an Event: > library(zoo) # na.locf > > lastEvent <- with(exData, na.locf(ife

Re: [R] moving average on irregular time series

2010-06-03 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Gustaf Rydevik > Sent: Thursday, June 03, 2010 7:24 AM > To: r-help@r-project.org > Subject: [R] moving average on irregular time series > > Hi all, >

[R] moving average on irregular time series

2010-06-03 Thread Gustaf Rydevik
Hi all, I wonder if there is any way to calculate a moving average on an irregular time series, or use the rollapply function in zoo? I have a set of dates where I want to check if there has been an event 14 days prior to each time point in order to mark these timepoints for removal, and can't fi