I have a data.frame and I want to list all records which have duplicates in columns "bod" and "datum". There is a very nice function duplicated
, unfortunatelly, it shows just one of the records:
visits2[duplicated(visits2[,c('bod','datum')]),]
Such handy function should be able to list all of the duplicates, shouldn't it? Or does R have a different handy function for that?
The only thing I was able to come up with is to call it twice like this, but that's pretty clumsy, so I consider it just a workaround:
visits2[duplicated(visits2[,c('bod','datum')]) | duplicated(visits2[,c('bod','datum')], fromLast = TRUE),]
I feel that for such a common task R deserves better solution than that! :-)
PS: please don't post answers writing "your own" functions for that... I know it can be done ;-) That's not the point. Perhaps the best thing would be to add a new option to duplicated()
.