here is an example data like mine. Think of it as a dataset of user activity on a website.
time | from | to |
---|---|---|
t0 | A | a |
t1 | a | b |
t2 | a | c |
t3 | a | d |
t4 | b | x1 |
t5 | b | x2 |
t6 | c | y1 |
t7 | x1 | a |
I want to generate hierarchical data. But like last row in dataset, there is infinite loop.
Parent is a then child is b.
Parent is b then child is x1.
Parent is x1 then child is a again. So here there is an infinite loop. So I can't use my original data because of that.
So my question is, how can i remove rows like the end?
Thank you.
I've tried to write some loop functions. But i couldn't.
PS: Edit example data