I have the following vector:
c("a", "a", "b", "a", "a", "c", "c", "c")
and I would like to split its elements into several groups according to the near same value.
the result is like this:
[[1]] ("a", "a"), [[2]]("b"), [[3]]("a", "a"), [[4]]("c", "c", "c")
although the element of group 1 and group 3 is the same, they are not neighbor. so they belong to different group.
I try to using for loop to do it, but it is not good enough.
question from:
https://stackoverflow.com/questions/66048893/group-the-near-same-numbers-of-a-vector 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…