get rows of unique values by group

前端 未结 4 774
抹茶落季
抹茶落季 2021-01-19 02:29

I have a data.table and want to pick those lines of the data.table where some values of a variable x are unique relative to another variable y

It\'s possible to get

4条回答
  •  我在风中等你
    2021-01-19 02:59

    Thanks to dplyR

    library(dplyr)
    col1 = c(1,1,3,3,5,6,7,8,9)
    col2 = c("cust1", 'cust1', 'cust3', 'cust4', 'cust5', 'cust5', 'cust5',     'cust5', 'cust6')
    df1 = data.frame(col1, col2)
    df1
    
    distinct(select(df1, col1, col2))
    

提交回复
热议问题