list <- c(1,1,1,4,5,6,9,9,2)
I want to find the index of the 3 lowest values , but with the condition that the index of the found minima is at least 3 points apart from each other. To find the 3 lowest indices I'm using
which(list <= sort(list, decreasing=FALSE)[3], arr.ind=TRUE)
which doesn't look for any conditions and results in
1,2,3
My desired result is
1,9,4
I want to know if it's possible doing that without any loops since my list is a lot bigger.
Thank you so much in advance.
To clarify what I meant: The indices of minima must always be in a certain distance. For example for the list
list<-c(1,3,9,5,9,9,2)
the result of the minima should be1,7,4
. Not1,7,2
, because that the indices 1 and 2 are too close together. Thank you again for helping me.