我当前使用的代码是...
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 2 9
我想保留重复的行并让输出为..
[1] 1 1 2 9
这可能吗?
感谢您的帮助。
最佳答案
试试这个:
sort(match(y,x))
[1] 1 1 2 9
关于r - 使用匹配功能保留重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31296758/