Similar to this question, I have a data frame and would like to extract the rows that are not unique in their combination of values in several specific columns.
E.g., I have a data frame df:
> df<-data.frame(c(1,2,3,4),c(T,F,T,T),c("a","b","c","b"),c("b","d","e","a"))
> df
[,1] [,2] [,3] [,4]
[1,] "1" "TRUE" "a" "b"
[2,] "2" "FALSE" "b" "d"
[3,] "3" "TRUE" "c" "e"
[4,] "4" "TRUE" "b" "a"
I would like to test whether the combination of values in coumn 2, 3 and 4 is unique or duplicate for the rows of the data frame. However, I don't want to classify the first occurence of a combination as unique and all subsequent combinations as duplicates but rather all occurences of non-unique combinations as duplicates.
In this example, rows 1 and 4 are duplicates and rows 2 and 3 are unique in their combinations of values in columns 2, 3 and 4.
Any help would be much appreciated.