Last active
November 23, 2021 02:37
-
-
Save alexpreynolds/6c7e86ad3e0d910164c8c296362c8ac8 to your computer and use it in GitHub Desktop.
Find local minima and maxima
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install.packages("quantmod") | |
library("quantmod") | |
x <- seq(0, 2*pi, 0.1) | |
y <- sin(x) | |
y[findPeaks(y)] | |
# [1] 0.9916648 | |
y[findPeaks(-y)] | |
# [1] -0.9961646 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment