This question is related to this Wide a dataframe and insert missing columns
Suppose we have a given pattern of 5 elements in this order: "A", "B", "C", "D", "E"
This pattern is repeated say 10 times. But sometimes some elements are lacking (see picture my vector (orange).
Is it possible in R to recognize the repeated pattern and fill in the lacking elements (see picture my desired output).
My vector:
my.vector <- c("A", "B", "C", "D", "E", "A", "B", "C", "D", "E", "B", "C",
"D", "E", "B", "C", "D", "E", "B", "C", "D", "E", "B", "C", "D",
"E", "B", "C", "D", "E", "B", "C", "D", "E", "A", "B", "C", "D",
"E", "B")
my.vector
[1] "A" "B" "C" "D" "E" "A" "B" "C" "D" "E" "B" "C" "D" "E" "B" "C" "D" "E" "B" "C" "D" "E" "B" "C" "D" "E" "B" "C" "D" "E" "B" "C" "D" "E" "A" "B" "C" "D" "E" "B"
A graphical explanation:


