[R] moving average on irregular time series

Gustaf Rydevik gustaf.rydevik at gmail.com
Thu Jun 3 16:23:32 CEST 2010


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!

Gustaf


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
skype:gustaf_rydevik



More information about the R-help mailing list