Suppose you have the following data file:
x=data.frame(c(1,1,2,2,2,3),c("A","A","B","B","B","B"))
names(x)=c("v1","v2")
x
v1 v2
1 1 A
2 1 A
3 2 B
4 2 B
5 2 B
6 3 B
In this data frame, the value in v1I want to match the label in v2. However, as can be seen in this example, it Bhas more than one corresponding value.
Is there an elegant and quick way to find which labels in v2correspond to more than one value in v1?
The result that I want to ideally show is the values ββthat should be in our example c(2,3), as well as the line number that should be in our example r=c(5,6).
source
share