I need to find the index of the second, inconsistent, occurrence of a value in a vector.
Some examples of vectors:
Example a) 1 1 1 2 3 4 1 1 1 2 3 4
Example b) 1 2 3 1 1 1 3 5
Please note that vectors can have a different number of occurrences of each value and very large (more than 100,000 entries)
So, if the value in question is 1, in example a) the result should return the 7th position, and b) should return the 4th.
Thanks in advance for any help or advice you can provide.
Code Examples:
exampleA<-c(1, 1, 1, 2, 3, 4, 1, 1, 1, 2, 3, 4)
exampleB<-c(1, 2, 3, 1, 1, 1, 3, 5)