更新时间:2023-12-01 11:44:46
duplicateated() / code>有一个方法,用于
data.frame
s,这是为这种任务设计的:
duplicated()
has a method for data.frame
s, which is designed for just this sort of task:
df <- data.frame(a = c(1:4, 1:4),
b = c(4:1, 4:1),
d = LETTERS[1:8])
df[!duplicated(df[c("a", "b")]),]
# a b d
# 1 1 4 A
# 2 2 3 B
# 3 3 2 C
# 4 4 1 D