[R] moving average on irregular time series
gustaf.rydevik at gmail.com
Fri Jun 4 11:37:56 CEST 2010
Dear William and Gabor,
Both solutions worked, and my problem is now solved.
Many thanks to both of you!
> On Thu, Jun 3, 2010 at 10:23 AM, Gustaf Rydevik
> <gustaf.rydevik at gmail.com> wrote:
>> 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 figure out a good way to do it.
>> Many thanks in advance!
>> Example data:
>> exData<-structure(list(Datebegin = structure(c(14476, 14569, 14576, 14621,
>> 14627, 14632, 14661, 14671, 14705, 14715, 14751, 14756, 14495,
>> 14518, 14523, 14526, 14528, 14529, 14545, 14548), class = "Date"),
>> Event = c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
>> FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE,
>> TRUE, FALSE, FALSE, FALSE)), .Names = c("Datebegin", "Event"
>> ), row.names = c(NA, 20L), class = "data.frame")
>> ###In this example, row 18 is a date less than 14 days after an event
>> and should be marked for removal.
>> Gustaf Rydevik, M.Sci.
>> tel: +46(0)703 051 451
>> address:Essingetorget 40,112 66 Stockholm, SE
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
More information about the R-help