Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How can I use findpeaks to look for a sustained peak across 3 consecutive time intervals?

I am using this to look for sustained CPU usage of at least 3 minutes.

findpeaks(MyData$X.busy, threshold=80) ??

    Timestamp, X.busy
    2017-10-08 00:00:00, 10
    2017-10-08 00:01:00, 10
    2017-10-08 00:02:00, 10
    2017-10-08 00:03:00, 10
    2017-10-08 00:04:00, 10
    2017-10-08 00:05:00, 90 <---
    2017-10-08 00:06:00, 90 <---
    2017-10-08 00:07:00, 90 <---
    2017-10-08 00:08:00, 10
    2017-10-08 00:09:00, 10

Any advice is appreciated.

Lou

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
968 views
Welcome To Ask or Share your Answers For Others

1 Answer

Just had the same issue. The documentation is not quite clear on that, but reading the source code of findpeaks helped. A slightly modified version of your case, with one non-sustained peak in position 2:

 y  <- c(10, 11, 10, 10, 10, 90, 90, 90, 10, 10)
 pp <- "[+]{1,}[0]+[-]{1,}"
 findpeaks(y, peakpat=pp)

The key is the [0]+ which means stationary for at least 1. If you wanted to also include the first unsustained peak, you could do use [0]* instead.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...