I'm trying to build a sequence which takes the previous value and adds it to the sequence.
For example:
Var1 Var2
1 A
1 B
1 C
2 A
2 C
2 D
The output I'm looking for is:
Var1 Var2 Var3
1 A A
1 B A>B
1 C A>B>C
2 A A
2 C A>C
2 D A>C>D
Is there a package for this? The number of elements in the sequence can get quite large, so my current method using lag within dplyr isn't feasible without writing out the same piece of code n times (where n is the maximum number of elements in a sequence).