How to remove rows that have only 1 combination for a given ID

前端 未结 4 1861
时光说笑
时光说笑 2020-12-04 02:59

I have a dataframe like this

ID <- c(\"A\",\"A\",\"A\",\"B\",\"B\",\"C\",\"C\")
Measurement <- c (\"Length\",\"Breadth\",\"Breadth\",\"Breadth\",\"Leng         


        
4条回答
  •  甜味超标
    2020-12-04 03:46

    Another option is using anyDuplicated

    df[with(df, ave(as.character(Measurement), ID, FUN = anyDuplicated)!=0),]
    

提交回复
热议问题