作者:hang | 来源:互联网 | 2022-12-01 13:27
1> WeNYoBen..:
使用duplicated
与apply
apply(df,1,duplicated)
[,1] [,2] [,3]
[1,] FALSE FALSE FALSE
[2,] FALSE TRUE TRUE
[3,] FALSE TRUE FALSE
并替换为 NA
df[t(apply(df,1,duplicated))]=NA
df
label val val1
1 a x z
2 b
3 c d