0

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")?

M--
  • 25,431
  • 8
  • 61
  • 93
Zappageck
  • 122
  • 9
  • In the goal, the columns 'Origin', "Destination' aree not matching with the original data. Iss it ordereed – akrun Aug 27 '19 at 15:13
  • No, as stated in the original post the initial data is not ordered. That's the point. I need to order it in the way stated in the goal. If it were ordered from the beginning there would be no problem. The order is implicit from the relationship of items in the origin and destination column but so far I failed to derive an order from it in R. – Zappageck Aug 28 '19 at 07:47

0 Answers0