I have a series of data of 60,000 data which part of the data is as the figure 1 (the whole curve is not so nice and uniform like this image (some other part of data is as second image)) but there are many cycles with different period in my data.
I need to calculate the time of three red, green and purple rectangles for each of the cycles (** the time between each maximum and minimum and total time of cycles **)
Can you give me some ideas on how to do it in R ... is there any special command or package that I can use?
Premise is that the
mean
value of the data range is used to split the data into categories of peaks and not peaks. Then a running id is generated to group each set of data so an appropriatemin
ormax
value can be determined. Thehalf_cycle
provides the red and green boxes, whilefull_cycle
provides the purple box for max-to-max and min-to-min. There is likely room for improvement, but it gives a method that can be adjusted as needed.This sample uses random data since no sample data was provided.