Looking for a solution to do the following:
There are two vectors:
a <- c(2,1,3,4,7,6,5,9,8,10)
b <- c(3,2,1,6,5,4,7,8,9,10)
I would like to create a third vector that would give the order in which vector b needs to be reordered for it to be in the same order as a. In this case I would like to get:
c <- c(2,3,1,6,7,4,5,9,8,10)
so that:
> b[c] == a
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
This question does not refer to cases in which a and b are double vectors, which is why the following question is also asked r - reorder second double vector according to first double vector