# NOT RUN {
#--- Find the peaks (local minima and maxima),
# and also the border peak at index 29. First the local maxima:
x <- c(1:10, 9:1, 2:11)
peak_indices <- find_peaks(x, w=3, get_min=FALSE)
peak_indices
x[peak_indices]
# and now the local minima
peak_indices <- find_peaks(x, w=3, get_min=TRUE)
peak_indices
x[peak_indices]
#--- What exactly does the neigbohood parameter 'w' mean?
# At least w-many values need to be inbetween two consecutive peaks:
x <- -c(1:10, 9, 9, 11, 9:8, 7)
peak_indices <- find_peaks(x, w=3)
peak_indices
x[peak_indices]
x <- -c(1:10, 9, 9,9, 11, 9:8, 7)
peak_indices <- find_peaks(x, w=3)
peak_indices
x[peak_indices]
#--- What does the parameter 'strict' mean?
# If strict = TRUE, then the peak must be '<' (or '>')
# then the neighbors, other wise '<=' (or '>=')
x <- c(10:1, 1:10)
peak_indices <- find_peaks(x, w=3, strict = TRUE)
peak_indices
x[peak_indices]
peak_indices <- find_peaks(x, w=3, strict = FALSE)
peak_indices
x[peak_indices]
# }
Run the code above in your browser using DataLab