Often we wish to work with such data aligned so each row in
d2has the same
idxvalue as the same row (by row order) as
d1. This is an important data wrangling task, so there are many ways to achieve it in R, such as
dplyr::left_join(), or by sorting both tables into the same order and then using
However if you wish to preserve the order of the first table (which may not be sorted), you need one more trick.
Click through to see that one additional trick.