0

Let's say I have the following data.frame:

df <- structure(list(a = c(1, 1, 1, 4), b = c(2, 2, 3, 4), c = c("a", 
"b", "c", "d")), .Names = c("a", "b", "c"), row.names = c(NA, 
-4L), class = "data.frame")

> df
#   a b c
# 1 1 2 a
# 2 1 2 b
# 3 1 3 c
# 4 4 4 d 

if I want to extract get the duplicates considering only columns a and b:

df[duplicated(df[,c(1,2)]),]
#  a b c
#2 1 2 b

It is then possible to get the duplicates and the data? Which in this case would be:

#1 1 2 a
#2 1 2 b
DJJ
  • 2,481
  • 2
  • 28
  • 53

0 Answers0