I have two machines inspect different aspects of a product. So I have two sets of data with two systems generating IDs but the IDs are referring to the same product getting inspected. And the IDs in both system reset themselves every 10 products inspected. And sometimes one of the systems went wrong and has no ID or wrong ID generated. So the data sets look like this:
data set 1: data set 2:
timestamp1 ID1 value1 timestamp2 ID2 value2
9:01 am 1 0.1 9:02 am 1 10
9:03 am 2 0.8 9:04 am 2 15
9:05 am 3 0.1 9:07 am 3 10
9:09 am 4 0.1 9:11 am 0 n/a <-system wrong
9:11 am 5 0.1 9:15 am 6 17 ID 4&5 missing
9:13 am 6 0.1 9:16 am 7 10
...................... .....data continues
9:21 am 9 0.1 9:22 am 10 19
9:22 am 10 0.1 9:23 am 1 10 <- ID back to 1
9:23 am 1 0.1 9:24 am 2 10
9:01 am 2 0.1 9:25 am 3 10
I want to merge the two data sets into one so I have both systems' inspection values for the same product. The expected data sets should look like this:
timestamp1 ID1 value1 timestamp2 ID2 value2
9:01 am 1 0.1 9:02 am 1 10
9:03 am 2 0.8 9:04 am 2 15
9:05 am 3 0.1 9:07 am 3 10
9:09 am 4 0.1 9:11 am n/a n/a <-system wrong
9:11 am 5 0.1 n/a n/a n/a
9:13 am 6 0.1 9:15 am 6 17
9:14 am 7 0.1 9:16 am 7 10
..................data continues
9:23 am 1 0.1 9:23 am 1 10 <- ID back to 1
9:01 am 2 0.1 9:25 am 2 10
I tried several merge functions, the problem is that the ID resets itself every 10 product. There is no unique ID to match, the results I got from merge() function is all messed up. The real data sets usually has > 10,000 lines of data per production run. It's impossible to pick out those problems line by line. Can any one give some help ? Thanks.