Remove duplicates in vector to next value

Question:I have a vector consisting of integers which can take a finite number of values. Consider the case where the values is 0,1,2.a<-c(0,0,0,1,1,0,0,2,2,2)I want to delete replicates of values until the next differnet value. After doing this the resul