I need to filter a very large data frame to remove repeating factor levels. The issue is that factor levels may repeat, as long as they are not consecutive. Filtering unique factor levels is very easy, but I need a method that keeps non-consecutive replicate factor levels.
For example, consider the vector A, A, A, B, B, A, C, C, C, C, B, B, B.
I need to filter that down to A, B, A, C, B.
This would ultimately be applied to a data frame in which rows are kept, but for simplicity, the concept/question applies to a vector.
I am guessing this is easier than I think it is, but any ideas are welcome!