0

I am trying to extract peaks (local maxima) and valleys (local minima) from time series data for further analysis.

I tried Excel but it did not capture these attributes as I want (see image). The squares with filled circles are the peaks and valleys I desire. The empty squares indicated by black arrows depict in the data valleys that Excel did not capture.

As seen in the zoomed in inset graph, I want to extract data from the square with filled circle to the empty square. Thanks once again. Although I am a green horn using R, but I believe I can do this extraction in R.

Peaks_Valleys from Excel

enter image description here

How to go about this extraction using R? Python reproducible code too is welcomed.

               time barometer
1   6/16/2023 16:30      0.17
2   6/16/2023 17:00      0.17
3   6/16/2023 17:30      0.16
4   6/16/2023 18:00      0.16
5   6/16/2023 18:30      0.16
6   6/16/2023 19:00      0.17
7   6/16/2023 19:30      0.19
8   6/16/2023 20:00      0.19
9   6/16/2023 20:30      0.18
10  6/16/2023 21:00      0.18
11  6/16/2023 21:30      0.18
12  6/16/2023 22:00      0.18
13  6/16/2023 22:30      0.18
14  6/16/2023 23:00      0.18
15  6/16/2023 23:30      0.18
16   6/17/2023 0:00      0.18
17   6/17/2023 0:30      0.18
18   6/17/2023 1:00      0.18
19   6/17/2023 1:30      0.18
20   6/17/2023 2:00      0.18
21   6/17/2023 2:30      0.18
22   6/17/2023 3:00      0.18
23   6/17/2023 3:30      0.18
24   6/17/2023 4:00      0.18
25   6/17/2023 4:30      0.18
26   6/17/2023 5:00      0.18
27   6/17/2023 5:30      0.18
28   6/17/2023 6:00      0.18
29   6/17/2023 6:30      0.18
30   6/17/2023 7:00      0.18
31   6/17/2023 7:30      0.18
32   6/17/2023 8:00      0.17
33   6/17/2023 8:30      0.17
34   6/17/2023 9:00      0.17
35   6/17/2023 9:30      0.17
36  6/17/2023 10:00      0.17
37  6/17/2023 10:30      0.17
38  6/17/2023 11:00      0.17
39  6/17/2023 11:30      0.17
40  6/17/2023 12:00      0.16
41  6/17/2023 12:30      0.17
42  6/17/2023 13:00      0.17
43  6/17/2023 13:30      0.16
44  6/17/2023 14:00      0.16
45  6/17/2023 14:30      0.16
46  6/17/2023 15:00      0.16
47  6/17/2023 15:30      0.16
48  6/17/2023 16:00      0.16
49  6/17/2023 16:30      0.16
50  6/17/2023 17:00      0.16
51  6/17/2023 17:30      0.16
52  6/17/2023 18:00      0.16
53  6/17/2023 18:30      0.15
54  6/17/2023 19:00      0.15
55  6/17/2023 19:30      0.15
56  6/17/2023 20:00      0.15
57  6/17/2023 20:30      0.15
58  6/17/2023 21:00      0.15
59  6/17/2023 21:30      0.15
60  6/17/2023 22:00      0.15
61  6/17/2023 22:30      0.15
62  6/17/2023 23:00      0.15
63  6/17/2023 23:30      0.15
64   6/18/2023 0:00      0.15
65   6/18/2023 0:30      0.15
66   6/18/2023 1:00      0.15
67   6/18/2023 1:30      0.15
68   6/18/2023 2:00      0.15
69   6/18/2023 2:30      0.15
70   6/18/2023 3:00      0.15
71   6/18/2023 3:30      0.15
72   6/18/2023 4:00      0.15
73   6/18/2023 4:30      0.15
74   6/18/2023 5:00      0.15
75   6/18/2023 5:30      0.15
76   6/18/2023 6:00      0.15
77   6/18/2023 6:30      0.15
78   6/18/2023 7:00      0.14
79   6/18/2023 7:30      0.14
80   6/18/2023 8:00      0.14
81   6/18/2023 8:30      0.14
82   6/18/2023 9:00      0.14
83   6/18/2023 9:30      0.14
84  6/18/2023 10:00      0.14
85  6/18/2023 10:30      0.14
86  6/18/2023 11:00      0.14
87  6/18/2023 11:30      0.14
88  6/18/2023 12:00      0.14
89  6/18/2023 12:30      0.14
90  6/18/2023 13:00      0.14
91  6/18/2023 13:30      0.14
92  6/18/2023 14:00      0.14
93  6/18/2023 14:30      0.14
94  6/18/2023 15:00      0.14
95  6/18/2023 15:30      0.14
96  6/18/2023 16:00      0.14
97  6/18/2023 16:30      0.14
98  6/18/2023 17:00      0.14
99  6/18/2023 17:30      0.14
100 6/18/2023 18:00      0.14
101 6/18/2023 18:30      0.14
102 6/18/2023 19:00      0.14
103 6/18/2023 19:30      0.14
104 6/18/2023 20:00      0.14
105 6/18/2023 20:30      0.14
106 6/18/2023 21:00      0.14
107 6/18/2023 21:30      0.13
108 6/18/2023 22:00      0.13
109 6/18/2023 22:30      0.13
110 6/18/2023 23:00      0.13
111 6/18/2023 23:30      0.13
112  6/19/2023 0:00      0.13
113  6/19/2023 0:30      0.13
114  6/19/2023 1:00      0.13
115  6/19/2023 1:30      0.13
116  6/19/2023 2:00      0.13
117  6/19/2023 2:30      0.13
118  6/19/2023 3:00      0.13
119  6/19/2023 3:30      0.13
120  6/19/2023 4:00      0.13
121  6/19/2023 4:30      0.13
122  6/19/2023 5:00      0.13
123  6/19/2023 5:30      0.13
124  6/19/2023 6:00      0.13
125  6/19/2023 6:30      0.13
126  6/19/2023 7:00      0.13
127  6/19/2023 7:30      0.13
128  6/19/2023 8:00      0.13
129  6/19/2023 8:30      0.13
130  6/19/2023 9:00      0.13
131  6/19/2023 9:30      0.13
132 6/19/2023 10:00      0.13
133 6/19/2023 10:30      0.13
134 6/19/2023 11:00      0.13
135 6/19/2023 11:30      0.13
136 6/19/2023 12:00      0.13
137 6/19/2023 12:30      0.12
138 6/19/2023 13:00      0.13
139 6/19/2023 13:30      0.12
140 6/19/2023 14:00      0.12
141 6/19/2023 14:30      0.12
142 6/19/2023 15:00      0.12
143 6/19/2023 15:30      0.12
144 6/19/2023 16:00      0.12
145 6/19/2023 16:30      0.12
146 6/19/2023 17:00      0.12
147 6/19/2023 17:30      0.12
148 6/19/2023 18:00      0.12
149 6/19/2023 18:30      0.11
150 6/19/2023 19:00      0.11
151 6/19/2023 19:30      0.11
152 6/19/2023 20:00      0.11
153 6/19/2023 20:30      0.11
154 6/19/2023 21:00      0.11
155 6/19/2023 21:30      0.11
156 6/19/2023 22:00      0.11
157 6/19/2023 22:30      0.11
158 6/19/2023 23:00      0.11
159 6/19/2023 23:30      0.11
160  6/20/2023 0:00      0.11
161  6/20/2023 0:30      0.11
162  6/20/2023 1:00      0.11
163  6/20/2023 1:30      0.11
164  6/20/2023 2:00      0.11
165  6/20/2023 2:30      0.11
166  6/20/2023 3:00      0.11
167  6/20/2023 3:30      0.11
168  6/20/2023 4:00      0.11
169  6/20/2023 4:30      0.11
170  6/20/2023 5:00      0.11
171  6/20/2023 5:30      0.11
172  6/20/2023 6:00      0.11
173  6/20/2023 6:30      0.11
174  6/20/2023 7:00      0.11
175  6/20/2023 7:30      0.11
176  6/20/2023 8:00      0.10
177  6/20/2023 8:30      0.10
178  6/20/2023 9:00      0.10
179  6/20/2023 9:30      0.10
180 6/20/2023 10:00      0.10
181 6/20/2023 10:30      0.10
182 6/20/2023 11:00      0.10
183 6/20/2023 11:30      0.10
184 6/20/2023 12:00      0.10
185 6/20/2023 12:30      0.10
186 6/20/2023 13:00      0.10
187 6/20/2023 13:30      0.10
188 6/20/2023 14:00      0.10
189 6/20/2023 14:30      0.10
190 6/20/2023 15:00      0.10
191 6/20/2023 15:30      0.09
192 6/20/2023 16:00      0.09
193 6/20/2023 16:30      0.09
194 6/20/2023 17:00      0.09
195 6/20/2023 17:30      0.09
196 6/20/2023 18:00      0.09
197 6/20/2023 18:30      0.09
198 6/20/2023 19:00      0.09
199 6/20/2023 19:30      0.09
200 6/20/2023 20:00      0.09
201 6/20/2023 20:30      0.09
202 6/20/2023 21:00      0.08
203 6/20/2023 21:30      0.08
204 6/20/2023 22:00      0.08
205 6/20/2023 22:30      0.08
206 6/20/2023 23:00      0.08
207 6/20/2023 23:30      0.08
208  6/21/2023 0:00      0.08
209  6/21/2023 0:30      0.08
210  6/21/2023 1:00      0.08
211  6/21/2023 1:30      0.08
212  6/21/2023 2:00      0.08
213  6/21/2023 2:30      0.08
214  6/21/2023 3:00      0.08
215  6/21/2023 3:30      0.08
216  6/21/2023 4:00      0.08
217  6/21/2023 4:30      0.08
218  6/21/2023 5:00      0.08
219  6/21/2023 5:30      0.08
220  6/21/2023 6:00      0.08
221  6/21/2023 6:30      0.08
222  6/21/2023 7:00      0.08
223  6/21/2023 7:30      0.08
224  6/21/2023 8:00      0.08
225  6/21/2023 8:30      0.08
226  6/21/2023 9:00      0.08
227  6/21/2023 9:30      0.08
228 6/21/2023 10:00      0.08
229 6/21/2023 10:30      0.08
230 6/21/2023 11:00      0.08
231 6/21/2023 11:30      0.08
232 6/21/2023 12:00      0.08
233 6/21/2023 12:30      0.08
234 6/21/2023 13:00      0.08
235 6/21/2023 13:30      0.08
236 6/21/2023 14:00      0.08
237 6/21/2023 14:30      0.08
238 6/21/2023 15:00      0.08
239 6/21/2023 15:30      0.08
240 6/21/2023 16:00      0.09
241 6/21/2023 16:30      0.08
242 6/21/2023 17:00      0.08
243 6/21/2023 17:30      0.08
244 6/21/2023 18:00      0.08
245 6/21/2023 18:30      0.07
246 6/21/2023 19:00      0.08
247 6/21/2023 19:30      0.07
248 6/21/2023 20:00      0.07
249 6/21/2023 20:30      0.07
250 6/21/2023 21:00      0.07
251 6/21/2023 21:30      0.07
252 6/21/2023 22:00      0.07
253 6/21/2023 22:30      0.07
254 6/21/2023 23:00      0.07
255 6/21/2023 23:30      0.07
256  6/22/2023 0:00      0.07
257  6/22/2023 0:30      0.07
258  6/22/2023 1:00      0.07
259  6/22/2023 1:30      0.07
260  6/22/2023 2:00      0.07
261  6/22/2023 2:30      0.07
262  6/22/2023 3:00      0.07
263  6/22/2023 3:30      0.07
264  6/22/2023 4:00      0.07
265  6/22/2023 4:30      0.07
266  6/22/2023 5:00      0.07
267  6/22/2023 5:30      0.07
268  6/22/2023 6:00      0.07
269  6/22/2023 6:30      0.07
270  6/22/2023 7:00      0.07
271  6/22/2023 7:30      0.07
272  6/22/2023 8:00      0.07
273  6/22/2023 8:30      0.07
274  6/22/2023 9:00      0.07
275  6/22/2023 9:30      0.06
276 6/22/2023 10:00      0.07
277 6/22/2023 10:30      0.06
278 6/22/2023 11:00      0.07
279 6/22/2023 11:30      0.06
280 6/22/2023 12:00      0.06
281 6/22/2023 12:30      0.06
282 6/22/2023 13:00      0.06
283 6/22/2023 13:30      0.06
284 6/22/2023 14:00      0.06
285 6/22/2023 14:30      0.06
286 6/22/2023 15:00      0.06
287 6/22/2023 15:30      0.06
288 6/22/2023 16:00      0.06
289 6/22/2023 16:30      0.06
290 6/22/2023 17:00      0.06
291 6/22/2023 17:30      0.05
292 6/22/2023 18:00      0.05
293 6/22/2023 18:30      0.05
294 6/22/2023 19:00      0.05
295 6/22/2023 19:30      0.05
296 6/22/2023 20:00      0.05
297 6/22/2023 20:30      0.05
298 6/22/2023 21:00      0.05
299 6/22/2023 21:30      0.05
300 6/22/2023 22:00      0.05
301 6/22/2023 22:30      0.05
302 6/22/2023 23:00      0.05
303 6/22/2023 23:30      0.05
304  6/23/2023 0:00      0.05
305  6/23/2023 0:30      0.05
306  6/23/2023 1:00      0.05
307  6/23/2023 1:30      0.05
308  6/23/2023 2:00      0.05
309  6/23/2023 2:30      0.05
310  6/23/2023 3:00      0.05
311  6/23/2023 3:30      0.05
312  6/23/2023 4:00      0.05
313  6/23/2023 4:30      0.05
314  6/23/2023 5:00      0.05
315  6/23/2023 5:30      0.05
316  6/23/2023 6:00      0.05
317  6/23/2023 6:30      0.05
318  6/23/2023 7:00      0.05
319  6/23/2023 7:30      0.05
320  6/23/2023 8:00      0.05
321  6/23/2023 8:30      0.05
322  6/23/2023 9:00      0.05
323  6/23/2023 9:30      0.05
324 6/23/2023 10:00      0.04
325 6/23/2023 10:30      0.04
326 6/23/2023 11:00      0.05
327 6/23/2023 11:30      0.04
328 6/23/2023 12:00      0.04
329 6/23/2023 12:30      0.04
330 6/23/2023 13:00      0.04
331 6/23/2023 13:30      0.05
332 6/23/2023 14:00      0.04
333 6/23/2023 14:30      0.04
334 6/23/2023 15:00      0.05
335 6/23/2023 15:30      0.04
336 6/23/2023 16:00      0.04
337 6/23/2023 16:30      0.04
338 6/23/2023 17:00      0.04
339 6/23/2023 17:30      0.04
340 6/23/2023 18:00      0.15
341 6/23/2023 18:30      1.73
342 6/23/2023 19:00      1.44
343 6/23/2023 19:30      0.74
344 6/23/2023 20:00      0.66
345 6/23/2023 20:30      0.62
346 6/23/2023 21:00      0.60
347 6/23/2023 21:30      0.59
348 6/23/2023 22:00      0.58
349 6/23/2023 22:30      0.57
Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
TripleJ
  • 11
  • 2
  • There are several packages at CRAN that will either find the peak value or do a smoothing fit and find the peak of the fit. Take a look at the "Task Views" page – Carl Witthoft Jul 29 '23 at 15:12
  • 1
    You haven't included your data. You have included a _picture_ of your data, which is not the same thing. We cannot copy / paste this picture into our console to recreate your data, and it seems unreasonable to expect anyone to transcribe your data when you could simply include it as text. Please [edit] your question to include _reproducible_ code and data, rather than images. Thanks. – Allan Cameron Jul 29 '23 at 15:25
  • Thank you so much Allan for the feedback. Just signed up to stack overflow today. Been combing the internet since yesterday without success. Trying to upload my data but I am having the issue of a newbie :D. – TripleJ Jul 29 '23 at 16:29
  • @CarlWitthoft : Thank you for chiming in. Been doing that since yesterday, including looking at YouTube (maybe I am not checking properly). Only Python has a video on it. In a paper that analyzed similar data, they used Python. Perhaps I have to learn Python for this task. – TripleJ Jul 29 '23 at 16:36
  • 2
    If you search SO for `[r] local peaks` or `[r] local maxima` you should see a variety of questions and answers like this one: https://stackoverflow.com/questions/6836409/finding-local-maxima-and-minima/6836955#6836955 – Jon Spring Jul 29 '23 at 16:55
  • This is just two rows of the dataset. I have 2001 records/rows in total. I cannot seem to be able to upload it. Please any suggestions? Thank you. – TripleJ Jul 29 '23 at 17:11
  • @JonSpring: Thank you. I have seen this. If I told you I had barely slept for over 5 overs out of 48 hours for this simple task (I know it is...but coding I must learn) and other things would you believe? The example here is a ID vector I have something like X,Y in 2000 records! – TripleJ Jul 29 '23 at 17:16
  • @TripleJ from looking at your data,if your data frame is called `dat` and your columns are called `time` and `barometer`, I think simply `dat[abs(diff(dat$barometer)) > 0.1,]` should get the subset of points you want. – Allan Cameron Jul 29 '23 at 17:44
  • @AllanCameron I appreciate your taking a look at the data. Please do I need to install any packages? I saw quantmod package where you get the functions (I suppose) stat_peaks and stat_valleys. But it is not on R version 4.3....So my question is, do I need to install any packages to use your code? Thanks – TripleJ Jul 29 '23 at 17:52
  • @TripleJ no, it's base R. And you might need to play around with the 0.1 threshold. – Allan Cameron Jul 29 '23 at 17:58

1 Answers1

0

The particular points you are looking for seem to occur either where there is an abrupt upwards or downwards change. If there are several rapid increases or decreases in a row, you need the first of these. The first thing we need to do is convert your time column into actual date-times:

dat$time <- as.POSIXct(dat$time, format = "%m/%d/%Y %H:%S")

Now we get the change between consecutive measurements:

changes <- c(diff(dat$barometer), 0)

Now we carry out run-length encoding of whether the value changes by more than 0.1. We need to do this in both the positive and negative sense :

pos_change <- rle(abs(changes) > 0.1 & sign(changes) == 1)
neg_change <- rle(abs(changes) > 0.1 & sign(changes) == -1)

Now we find the start of each run encoding:

pos <- with(pos_change, cumsum(lengths)[values == "TRUE"]) - 1
neg <- with(neg_change, cumsum(lengths)[values == "TRUE"]) - 1

Now we use this to subset our original data frame to get our final result:

changes <- dat[sort(c(pos, neg)),]

And the final result looks like this:

changes
#>                    time barometer
#> 339 2023-06-23 17:00:30      0.04
#> 341 2023-06-23 18:00:30      1.73

Let's plot our original data and overplot changes in red:

plot(dat, type = "l")
points(changes, col = "red")

Created on 2023-07-29 with reprex v2.0.2


Reproducible data

dat <- structure(list(time = c("6/16/2023 16:30", "6/16/2023 17:00", 
"6/16/2023 17:30", "6/16/2023 18:00", "6/16/2023 18:30", "6/16/2023 19:00", 
"6/16/2023 19:30", "6/16/2023 20:00", "6/16/2023 20:30", "6/16/2023 21:00", 
"6/16/2023 21:30", "6/16/2023 22:00", "6/16/2023 22:30", "6/16/2023 23:00", 
"6/16/2023 23:30", "6/17/2023 0:00", "6/17/2023 0:30", "6/17/2023 1:00", 
"6/17/2023 1:30", "6/17/2023 2:00", "6/17/2023 2:30", "6/17/2023 3:00", 
"6/17/2023 3:30", "6/17/2023 4:00", "6/17/2023 4:30", "6/17/2023 5:00", 
"6/17/2023 5:30", "6/17/2023 6:00", "6/17/2023 6:30", "6/17/2023 7:00", 
"6/17/2023 7:30", "6/17/2023 8:00", "6/17/2023 8:30", "6/17/2023 9:00", 
"6/17/2023 9:30", "6/17/2023 10:00", "6/17/2023 10:30", "6/17/2023 11:00", 
"6/17/2023 11:30", "6/17/2023 12:00", "6/17/2023 12:30", "6/17/2023 13:00", 
"6/17/2023 13:30", "6/17/2023 14:00", "6/17/2023 14:30", "6/17/2023 15:00", 
"6/17/2023 15:30", "6/17/2023 16:00", "6/17/2023 16:30", "6/17/2023 17:00", 
"6/17/2023 17:30", "6/17/2023 18:00", "6/17/2023 18:30", "6/17/2023 19:00", 
"6/17/2023 19:30", "6/17/2023 20:00", "6/17/2023 20:30", "6/17/2023 21:00", 
"6/17/2023 21:30", "6/17/2023 22:00", "6/17/2023 22:30", "6/17/2023 23:00", 
"6/17/2023 23:30", "6/18/2023 0:00", "6/18/2023 0:30", "6/18/2023 1:00", 
"6/18/2023 1:30", "6/18/2023 2:00", "6/18/2023 2:30", "6/18/2023 3:00", 
"6/18/2023 3:30", "6/18/2023 4:00", "6/18/2023 4:30", "6/18/2023 5:00", 
"6/18/2023 5:30", "6/18/2023 6:00", "6/18/2023 6:30", "6/18/2023 7:00", 
"6/18/2023 7:30", "6/18/2023 8:00", "6/18/2023 8:30", "6/18/2023 9:00", 
"6/18/2023 9:30", "6/18/2023 10:00", "6/18/2023 10:30", "6/18/2023 11:00", 
"6/18/2023 11:30", "6/18/2023 12:00", "6/18/2023 12:30", "6/18/2023 13:00", 
"6/18/2023 13:30", "6/18/2023 14:00", "6/18/2023 14:30", "6/18/2023 15:00", 
"6/18/2023 15:30", "6/18/2023 16:00", "6/18/2023 16:30", "6/18/2023 17:00", 
"6/18/2023 17:30", "6/18/2023 18:00", "6/18/2023 18:30", "6/18/2023 19:00", 
"6/18/2023 19:30", "6/18/2023 20:00", "6/18/2023 20:30", "6/18/2023 21:00", 
"6/18/2023 21:30", "6/18/2023 22:00", "6/18/2023 22:30", "6/18/2023 23:00", 
"6/18/2023 23:30", "6/19/2023 0:00", "6/19/2023 0:30", "6/19/2023 1:00", 
"6/19/2023 1:30", "6/19/2023 2:00", "6/19/2023 2:30", "6/19/2023 3:00", 
"6/19/2023 3:30", "6/19/2023 4:00", "6/19/2023 4:30", "6/19/2023 5:00", 
"6/19/2023 5:30", "6/19/2023 6:00", "6/19/2023 6:30", "6/19/2023 7:00", 
"6/19/2023 7:30", "6/19/2023 8:00", "6/19/2023 8:30", "6/19/2023 9:00", 
"6/19/2023 9:30", "6/19/2023 10:00", "6/19/2023 10:30", "6/19/2023 11:00", 
"6/19/2023 11:30", "6/19/2023 12:00", "6/19/2023 12:30", "6/19/2023 13:00", 
"6/19/2023 13:30", "6/19/2023 14:00", "6/19/2023 14:30", "6/19/2023 15:00", 
"6/19/2023 15:30", "6/19/2023 16:00", "6/19/2023 16:30", "6/19/2023 17:00", 
"6/19/2023 17:30", "6/19/2023 18:00", "6/19/2023 18:30", "6/19/2023 19:00", 
"6/19/2023 19:30", "6/19/2023 20:00", "6/19/2023 20:30", "6/19/2023 21:00", 
"6/19/2023 21:30", "6/19/2023 22:00", "6/19/2023 22:30", "6/19/2023 23:00", 
"6/19/2023 23:30", "6/20/2023 0:00", "6/20/2023 0:30", "6/20/2023 1:00", 
"6/20/2023 1:30", "6/20/2023 2:00", "6/20/2023 2:30", "6/20/2023 3:00", 
"6/20/2023 3:30", "6/20/2023 4:00", "6/20/2023 4:30", "6/20/2023 5:00", 
"6/20/2023 5:30", "6/20/2023 6:00", "6/20/2023 6:30", "6/20/2023 7:00", 
"6/20/2023 7:30", "6/20/2023 8:00", "6/20/2023 8:30", "6/20/2023 9:00", 
"6/20/2023 9:30", "6/20/2023 10:00", "6/20/2023 10:30", "6/20/2023 11:00", 
"6/20/2023 11:30", "6/20/2023 12:00", "6/20/2023 12:30", "6/20/2023 13:00", 
"6/20/2023 13:30", "6/20/2023 14:00", "6/20/2023 14:30", "6/20/2023 15:00", 
"6/20/2023 15:30", "6/20/2023 16:00", "6/20/2023 16:30", "6/20/2023 17:00", 
"6/20/2023 17:30", "6/20/2023 18:00", "6/20/2023 18:30", "6/20/2023 19:00", 
"6/20/2023 19:30", "6/20/2023 20:00", "6/20/2023 20:30", "6/20/2023 21:00", 
"6/20/2023 21:30", "6/20/2023 22:00", "6/20/2023 22:30", "6/20/2023 23:00", 
"6/20/2023 23:30", "6/21/2023 0:00", "6/21/2023 0:30", "6/21/2023 1:00", 
"6/21/2023 1:30", "6/21/2023 2:00", "6/21/2023 2:30", "6/21/2023 3:00", 
"6/21/2023 3:30", "6/21/2023 4:00", "6/21/2023 4:30", "6/21/2023 5:00", 
"6/21/2023 5:30", "6/21/2023 6:00", "6/21/2023 6:30", "6/21/2023 7:00", 
"6/21/2023 7:30", "6/21/2023 8:00", "6/21/2023 8:30", "6/21/2023 9:00", 
"6/21/2023 9:30", "6/21/2023 10:00", "6/21/2023 10:30", "6/21/2023 11:00", 
"6/21/2023 11:30", "6/21/2023 12:00", "6/21/2023 12:30", "6/21/2023 13:00", 
"6/21/2023 13:30", "6/21/2023 14:00", "6/21/2023 14:30", "6/21/2023 15:00", 
"6/21/2023 15:30", "6/21/2023 16:00", "6/21/2023 16:30", "6/21/2023 17:00", 
"6/21/2023 17:30", "6/21/2023 18:00", "6/21/2023 18:30", "6/21/2023 19:00", 
"6/21/2023 19:30", "6/21/2023 20:00", "6/21/2023 20:30", "6/21/2023 21:00", 
"6/21/2023 21:30", "6/21/2023 22:00", "6/21/2023 22:30", "6/21/2023 23:00", 
"6/21/2023 23:30", "6/22/2023 0:00", "6/22/2023 0:30", "6/22/2023 1:00", 
"6/22/2023 1:30", "6/22/2023 2:00", "6/22/2023 2:30", "6/22/2023 3:00", 
"6/22/2023 3:30", "6/22/2023 4:00", "6/22/2023 4:30", "6/22/2023 5:00", 
"6/22/2023 5:30", "6/22/2023 6:00", "6/22/2023 6:30", "6/22/2023 7:00", 
"6/22/2023 7:30", "6/22/2023 8:00", "6/22/2023 8:30", "6/22/2023 9:00", 
"6/22/2023 9:30", "6/22/2023 10:00", "6/22/2023 10:30", "6/22/2023 11:00", 
"6/22/2023 11:30", "6/22/2023 12:00", "6/22/2023 12:30", "6/22/2023 13:00", 
"6/22/2023 13:30", "6/22/2023 14:00", "6/22/2023 14:30", "6/22/2023 15:00", 
"6/22/2023 15:30", "6/22/2023 16:00", "6/22/2023 16:30", "6/22/2023 17:00", 
"6/22/2023 17:30", "6/22/2023 18:00", "6/22/2023 18:30", "6/22/2023 19:00", 
"6/22/2023 19:30", "6/22/2023 20:00", "6/22/2023 20:30", "6/22/2023 21:00", 
"6/22/2023 21:30", "6/22/2023 22:00", "6/22/2023 22:30", "6/22/2023 23:00", 
"6/22/2023 23:30", "6/23/2023 0:00", "6/23/2023 0:30", "6/23/2023 1:00", 
"6/23/2023 1:30", "6/23/2023 2:00", "6/23/2023 2:30", "6/23/2023 3:00", 
"6/23/2023 3:30", "6/23/2023 4:00", "6/23/2023 4:30", "6/23/2023 5:00", 
"6/23/2023 5:30", "6/23/2023 6:00", "6/23/2023 6:30", "6/23/2023 7:00", 
"6/23/2023 7:30", "6/23/2023 8:00", "6/23/2023 8:30", "6/23/2023 9:00", 
"6/23/2023 9:30", "6/23/2023 10:00", "6/23/2023 10:30", "6/23/2023 11:00", 
"6/23/2023 11:30", "6/23/2023 12:00", "6/23/2023 12:30", "6/23/2023 13:00", 
"6/23/2023 13:30", "6/23/2023 14:00", "6/23/2023 14:30", "6/23/2023 15:00", 
"6/23/2023 15:30", "6/23/2023 16:00", "6/23/2023 16:30", "6/23/2023 17:00", 
"6/23/2023 17:30", "6/23/2023 18:00", "6/23/2023 18:30", "6/23/2023 19:00", 
"6/23/2023 19:30", "6/23/2023 20:00", "6/23/2023 20:30", "6/23/2023 21:00", 
"6/23/2023 21:30", "6/23/2023 22:00", "6/23/2023 22:30"), barometer = c(0.17, 
0.17, 0.16, 0.16, 0.16, 0.17, 0.19, 0.19, 0.18, 0.18, 0.18, 0.18, 
0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 
0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.18, 0.17, 0.17, 0.17, 
0.17, 0.17, 0.17, 0.17, 0.17, 0.16, 0.17, 0.17, 0.16, 0.16, 0.16, 
0.16, 0.16, 0.16, 0.16, 0.16, 0.16, 0.16, 0.15, 0.15, 0.15, 0.15, 
0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 
0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.14, 
0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 
0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 
0.14, 0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 
0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 
0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 
0.13, 0.13, 0.13, 0.12, 0.13, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 
0.12, 0.12, 0.12, 0.12, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 
0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 
0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.1, 0.1, 
0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 
0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 
0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 
0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 
0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 
0.08, 0.08, 0.08, 0.08, 0.08, 0.09, 0.08, 0.08, 0.08, 0.08, 0.07, 
0.08, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 
0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 
0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.07, 0.06, 0.07, 0.06, 0.07, 
0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 0.06, 
0.06, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 
0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 
0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 
0.05, 0.04, 0.04, 0.05, 0.04, 0.04, 0.04, 0.04, 0.05, 0.04, 0.04, 
0.05, 0.04, 0.04, 0.04, 0.04, 0.04, 0.15, 1.73, 1.44, 0.74, 0.66, 
0.62, 0.6, 0.59, 0.58, 0.57)), row.names = c(NA, -349L), class = "data.frame")
Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
  • Thank you so much. I was running the code you provided earlier with the 0.1 cutoff. It reduced my data from 2001 to 44 observations/rows. You are correct, what I am looking for is the falling part of the graph/plot: all data points between any local maxima and the local minimum that follows i.e., abrupt downwards change. – TripleJ Jul 29 '23 at 18:32