bdLogical) denoting which values duplicate previous values.
unique(x, incomparables = F) duplicated(x, incomparables = F)
bdVector.
Missing values and
Infs are allowed.
bdFrame objects, or lists containing multiple vectors or
bdVectors.
bdVector of values that cannot be compared, each value in
x that matches
a value in this vector or
bdVector is considered unique.
If
incomparables=FALSE all values can be compared.
unique returns
an object like
x but with no duplicate values. The
values in the same order as
x except that
repeated values will be deleted.
duplicated returns a logical vector or
bdLogical the same length as
x
that tells for each element of
x whether that value has appeared
before in
x.
By default, any value is considered able to be duplicated.
The
incomparables argument allows you to select values that will always
be considered unique. (The values
TRUE and
FALSE are always able to
be duplicated.)
Both
duplicated and
unique
are generic.
It normally suffices to define a method for
duplicated
, as the default method for
unique
is implemented as
x[!duplicated(x,incomparables)].
If
x is a data frame or
bdFrame, then
duplicated(x)
returns a logical vector or
bdLogical
indicating which rows are duplicated, and
unique(x)
returns the unique rows.
To check multiple vectors or
bdVectors (of equal lengths)
for combinations of duplicated values, use
duplicated(list(var1,var2,...))
;
the calculations are carried out by
duplicated.data.frame
.
When
x is numeric, apparently equal values may not be considered equal
due to numerical imprecision.
sort(unique(names)) # sorted list of names with no duplicates unique(x[duplicated(x)]) # values that occur at least twice unique(x, incomp=c(1/0,-1/0)) # treat all infinities as unique