Reputation: 2890
Pretty basic question that im struggling to find an answer on...
If I have two vectors in R
, like so:
Name <- c(1,2,3,4)
Name_1 <- c(2,4,1,3)
Is there a way to reorder, say, the Name
vector so it matches the order of Name_1
?
That is, the resulting vector would look like this:
Result <- reorder(Name so that it = Name_1)
Result
> 2,4,1,3
Any suggestions as to how I do this in R
?
Upvotes: 1
Views: 283
Reputation: 1845
If all elements of Name_1 match with Name the 2 vectors are the same. However the solution should be:
Name[Name_1]
Upvotes: 1