سؤال

Is there a function that let me thin out my data (time-series as zoo)?

The Example would be

mytime<-as.POSIXct(paste("2013-07-09 12:", c(1:59), sep=""))
mydata<-EuStockMarkets[1:59]
myts<-zoo(mydata, mytime)

I search a function that returns an irregular timeseries with just those data, that are different to the previous timestep by lets say ten points.

Any idea with zoo??

Thank you

Bastian

هل كانت مفيدة؟

المحلول

Try subset:

> subset(myts, diff(myts) > 10)
2013-07-09 12:04:00 2013-07-09 12:07:00 2013-07-09 12:10:00 2013-07-09 12:22:00 
            1621.04             1630.75             1645.89             1616.67 
2013-07-09 12:28:00 2013-07-09 12:32:00 2013-07-09 12:37:00 2013-07-09 12:38:00 
            1631.87             1650.43             1524.28             1603.65 
2013-07-09 12:39:00 2013-07-09 12:40:00 2013-07-09 12:41:00 
            1622.49             1636.68             1652.10 

Use abs(diff(myts)) if either direction is needed.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top