View source: R/turning_points.R
do_find_turning_points | R Documentation |
Find turning points (minima and maxima) in a vector.
do_find_turning_points(.x, .return = c("value", "index"), .adjust = 1.5, ...)
.x |
A numeric vector |
.return |
A character giving the desired return type. |
.adjust |
A numeric giving the adjustment to the |
... |
Other parameters passed to |
A list with the two elements maxima
and minima
set.seed(1234)
.x <- c(rnorm(100, 2, 1), rnorm(100, 9, 1))
tpi <- do_find_turning_points(.x, .return = "index", .adjust = 1)
dx <- density(.x, adjust = 1, n = length(.x))
plot(dx)
points(dx$x[tpi$maxima], dx$y[tpi$maxima], pch = 19, col = "red")
points(dx$x[tpi$minima], dx$y[tpi$minima], pch = 19, col = "blue")
do_find_turning_points(.x, .return = "value", .adjust = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.