Finding ALL duplicate rows, including “elements with smaller subscripts”

后端 未结 7 725
借酒劲吻你
借酒劲吻你 2020-11-21 07:55

R\'s duplicated returns a vector showing whether each element of a vector or data frame is a duplicate of an element with a smaller subscript. So if rows 3, 4,

7条回答
  •  抹茶落季
    2020-11-21 08:37

    I've had the same question, and if I'm not mistaken, this is also an answer.

    vec[col %in% vec[duplicated(vec$col),]$col]
    

    Dunno which one is faster, though, the dataset I'm currently using isn't big enough to make tests which produce significant time gaps.

提交回复
热议问题