0

I have a numeric vector as following, and I would like to find out the local min in the sequence. in this case, that is 5th and 15th elements, or as indicated in the plot. How can I do this?

f <- function(x)  ifelse(x < 15 & x >5, 80,(x-10)^2)
x <- seq(1,20) %>% f() 
x[8:12] <- 5
plot(x)

# x
#[1]  81  64  49  36  25  80  80   5   5   5   5   5  80  80  25  36  49  64  81 100

enter image description here

I have tried method described in how to find local maximum in graph, yet it gives no result, I assume it's because that my data is discrete, not contineous.

Grec001
  • 1,111
  • 6
  • 20

0 Answers0