Next: unix Up: MacAnova Help File Previous: twotailt()   Contents

unique()

Usage:
 ```unique(x [,index:T, fuzz:d]), x REAL, LOGICAL or CHARACTER, d >= 0 a REAL scalar ```

Keywords: ordering, variables
```unique(x) computes a vector consisting of all the distinct non-MISSING
values in the REAL, LOGICAL or CHARACTER vector, matrix, or array x.
When x is REAL or LOGICAL, it is an error when all its elements are
MISSING.  If x1 contains the same values of x in a different order,
unique(x1) will return the same values as unique(x), but possibly in a
different order.

unique(x, index:T) computes a vector J of positive integers such that
x[J] is the same as unique(x).  That is it finds the subscripts of the
unique non-missing elements of x.

unique(x, fuzz:d [, index:T]), where x is REAL and d >= 0 is a REAL
scalar does the same, except that, as x is scanned, x[j] is determined
to be different from x[i], 1 <= i < j only if abs(x[j] - x[i]) > d.  The
numbers returned may depend on the ordering of values in x.  That is,
for example, unique(x, fuzz:d) and unique(sort(x),fuzz:d) may return
different sets of numbers.

Examples:
unique(vector(5,3,1,2,4,2,5,7,2,7)) returns vector(5,3,1,2,4,7).
unique(vector(5.1,3,2.9,3.5,5,2.6), fuzz:.15) returns
vector(5.1,3,3.5,2.6)
unique(sort(vector(5.1,3,2.9,3.5,5,2.6)), fuzz:.15) returns
vector(2.6,2.9,3.5,5)
unique(vector("B","C","A","B","D","A","A")) returns
vector("B","C","A","D")
unique(vector(T,T,T,F,T)) returns vector(T,F)
unique(vector("B","C","A","B","D","A","A"), index:T) returns
vector(1,2,3,5)
a <- factor(match(x,unique(x))) computes a factor each level of which
corresponds to a unique value of vector x.
a <- factor(match(x,sort(unique(x)))) computes a factor each level of
which corresponds to a unique value of vector x, with the factor
levels in the same numerical or alphabetic order as the elements of
x