R -- duplicated函数

duplicated(x, fromLast=FALSE, by=seq_along(x),)

  • X : A data.table. uniqueN accepts atomic vectors and data.frames as well.
  • fromLast : logical indicating if duplication should be considered from the reverse side, i.e., the last (or rightmost) of identical elements would correspond to duplicated = FALSE.
  • by : character or integer vector indicating which combinations of columns from x to use for uniqueness checks. By default all columns are being used. That was changed recently for consistency to data.frame methods.
  • returns a logical vector of length nrow(x) indicating which rows are duplicates.
duplicated(DT, by="B")

duplicated(DT, by=c("A", "C"))

duplicated(DT, by="B", fromLast=TRUE)
# 注意返回的是nrow(x)等长的包含逻辑值的向量
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值