R 使用Match函数保留副本

R 使用Match函数保留副本,r,duplicates,R,Duplicates,我目前使用的代码是 x <- c("1/1/1990", "2/1/1990", "3/1/1990", "4/1/1990", "5/1/1990", "6/1/1990", "7/1/1990", "8/1/1990", "9/1/1990", "10/1/1990", "11/1/1990") y <- c("1/1/1990","9/1/1990","1/1/1990","2/1/1990") test <-

我目前使用的代码是

x <- c("1/1/1990",  "2/1/1990",  "3/1/1990",
       "4/1/1990",  "5/1/1990",  "6/1/1990",
       "7/1/1990",  "8/1/1990",  "9/1/1990",  "10/1/1990", 
       "11/1/1990") 
y <- c("1/1/1990","9/1/1990","1/1/1990","2/1/1990")
test <- match(x,y)
position <- which(test > 0)
position
我希望保留重复的行,并使输出为

[1] 1 12 9

这可能吗

谢谢你的帮助

试试这个:

sort(match(y,x))
[1] 1 1 2 9
试试这个:

sort(match(y,x))
[1] 1 1 2 9