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)等长的包含逻辑值的向量