I have an input input matrix
df <- data.frame(a = c(1,1,2,4,3,5,2,1,1,3), b = c(4,3,3,1,2,2,4,4,4,2), d = LETTERS[1:10])
I want to get
out <- data.frame(a = c(1,2,4,3,1,1,3), b = c(4,3,1,2,4,4,2), d = c(A,C,D,E,H,I,J))
# a b d
# 1 1 4 A
# 2 2 3 C
# 3 4 1 D
# 4 3 2 E
# 5 1 4 H
# 6 1 4 I
# 7 3 2 J
I want to extract any rows that are duplicated in both columns – also in reverse order
I tried df[duplicated(df[c("a")]) | duplicated(df[c("b")]) ,]
but it does not work.
Any suggestion?