I have a file (called example.txt) that looks like the following:
A B C
D E F
H I C
Z B Y
A B C
T E F
W O F
Based on column 2, I would like to identify the duplicate rows to obtain the following file:
H I C
W O F
I have a file (called example.txt) that looks like the following:
A B C
D E F
H I C
Z B Y
A B C
T E F
W O F
Based on column 2, I would like to identify the duplicate rows to obtain the following file:
H I C
W O F
We can use duplicated
df1[!(duplicated(df1$col2)|duplicated(df1$col2, fromLast=TRUE)),]
# col1 col2 col3
#3 H I C
#7 W O F
You can just compute which values occur exactly once and select those rows - like this:
Tab = table(df$V2)
Vals = unlist(attr(Tab, "dimnames"))[which(Tab == 1)]
df[df$V2 %in% Vals, ]
V1 V2 V3
3 H I C
7 W O F