Origin Destination Data - Reshaping / Ordering / Path Replication

68 Views Asked by At

I have origin-destination data which is not ordered and want to deduct a path from it. Therefore I want to add an order column which contains the number of the "steps".

Following data table should contain the path of A-B-A-C-D-E:

DT_Test<-data.table(Origin=c("B","A","C","D","A"),Destination=c("A","C","D","E","B"),User=c("U56","U56","U56","U56","U56"))

Goal:

Data Table with Order Column

Is there any existing function/package to do this (with a by-statement on "User")?

0

There are 0 best solutions below