Unique or Duplicated Values

DESCRIPTION:

Returns the values of the input without any repetition, or a logical vector (or bdLogical) denoting which values duplicate previous values.

USAGE:

unique(x, incomparables = F) 
duplicated(x, incomparables = F) 

REQUIRED ARGUMENTS:

x
a vector or bdVector. Missing values and Infs are allowed.
Some methods handle other objects, such as data frames, bdFrame objects, or lists containing multiple vectors or bdVectors.

OPTIONAL ARGUMENTS:

incomparables
a vector or 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.

VALUE:

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.

DETAILS:

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 .

WARNING:

When x is numeric, apparently equal values may not be considered equal due to numerical imprecision.

SEE ALSO:

, , , .

EXAMPLES:

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