[R] More of a stats question I suppose...
Thomas Lumley
tlumley at u.washington.edu
Thu Nov 1 17:48:53 CET 2001
On Thu, 1 Nov 2001, Chris Milkosky wrote:
> Hi all. Sorry to post this here, but I figure that you may know the answer to my question...
>
> I analyze data sets very frequently, and it becomes cumbersome to try to find sustained peaks (my def - high points that exist for
> about 6 minutes or more - 3 poll intervals) in these data sets all the time. Right now I graph the data and then look for what
> looks to be a sustained peak and then go to the raw data itself to make the determination. I'm actually embarassed to say that I do
> that because it is SO time consuming and I'm sure there are other ways. I just haven't had the time to explore them. Well, now
> it's becoming more critical.
>
> So, here's my question - can anyone suggest a good method using R to analyze a set of data that consists of time (polled every 2
> minutes) and values at that time, so that I can just plop the data set in, and then have R find sustained peaks? Maybe then it can
> report them to me, or just point out the poll intervals where they occurred... Or something like that...
>
Suppose x is your series and you want to find more than LONG consecutive
values equal to HIGH or greater
p<-cumsum(x>HIGH)
padding<-rep(0,LONG)
longpeaks<-which(c(padding,p)+LONG==c(p,padding))
longpeaks now contains the index of the start of each long peak (in fact
it contains all but the first LONG-1 indices of each long peak, but that
shouldn't matter).
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list