I have a vector, X, looking like the following:
X = c(30, 10, 10, 15, 25, 1, 10, 55, 10, 1, 10, 5, 5, 5, 5, 10, 5, 5, 5, 5, 5, 5, 5, 5)
^
17
I want to make a function where if I input the above vector and a number, n, it shows where the consecutive n starts. In X above, the desired number is 17 if my n is 5 since starting the 17th location, the rest of the vector is all 5.
So, if I want a function, f, such that f(X,5) gives me 17. Can anyone help me on achieve this in the fastest manner?