In a list, find the numbers where they are bigger than the next numbers
I think the following is the easiest and fastest way:


Create a new vector with the "next neighbors"
Subtract the "neighbors" vector from the original vector
Determine which entries in the new vector are positive


I've actually never used R, but here's how I think it would work:

original_list &lt;- c(7, 7, 9, 9, 9, 10, 10, 1, 51, 51)
# extract the "right neighbors" of the original list elements
neighbors &lt;- original_list[-1]
# fill the missing position after the last element
neighbors &lt;- append(neighbors, 0)
# compute the difference between the original vector and the right-neighbors
diff &lt;- original_list - neighbors
# find the indices of positive elements
idx &lt;- which(diff &gt; 0)

# your output: elements which have a smaller right-neighbor
output &lt;- original_list[idx]