library(dplyr)
df <- tibble::tibble(  
  x = sample(10, 100, rep = TRUE),  
  y = sample(10, 100, rep = TRUE)  
)  
df
# 以全部列去重
distinct(df)

# 以列x去重,仅返回去重后的x列
distinct(df, x)  

# 以列x去重,返回所有列
distinct(df, x, .keep_all = TRUE)  

转自:# http://guangzheng.name/2017/10/08/dplyr%E5%8C%85%E4%B8%AD%E7%9A%84distinct%E5%87%BD%E6%95%B0/

相关文章:

  • 2021-12-10
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2021-11-12
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-11
  • 2021-12-28
  • 2021-07-13
  • 2021-12-11
  • 2022-12-23
  • 2021-08-16
  • 2022-01-12
相关资源
相似解决方案