簡體   English   中英

刪除數據框(R)所有列中具有重復值的行

[英]Removing row with duplicated values in all columns of a data frame (R)

具有以下數據框:

d <- structure(list(n = c(2, 3, 5), s = c(2, 8, 3),t = c(2, 18, 30)), .Names = c("n", "s","t"), row.names = c(NA, -3L), class = "data.frame")

看起來像:

> d
  n s  t
1 2 2  2
2 3 8 18
3 5 3 30

如何刪除所有列中具有重復值的行。 產量:

  n s  t
2 3 8 18
3 5 3 30

這是一種比較所有列與第一個列的方法

d[rowSums(d == d[,1]) != ncol(d),]
#   n s  t
# 2 3 8 18
# 3 5 3 30

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM