This is perhaps overcomplicated, but I would approach this task as follows:
An exemplary data frame:
(data2 <- data.frame(V1=1:10, V2=letters[1:10]))
## V1 V2
## 1 1 a
## 2 2 b
## 3 3 c
## 4 4 d
## 5 5 e
## 6 6 f
## 7 7 g
## 8 8 h
## 9 9 i
## 10 10 j
Let's find in which row we have a match (NA
- no match, i
- i-th value was matched):
(m <- match(data2$V1, c(5,1,7,3)))
## [1] 2 NA 4 NA 1 NA 3 NA NA NA
Now we select matching rows matches and permute them accordingly:
data2[!is.na(m),][order(na.omit(m)),]
## V1 V2
## 5 5 e
## 1 1 a
## 7 7 g
## 3 3 c
On the other hand, if you know that V1
consists of consecutive natural numbers (starting from 1), the solution is easy as 1-2-3:
data2[c(5,1,7,3),]
## V1 V2
## 5 5 e
## 1 1 a
## 7 7 g
## 3 3 c