Skip to contents

Similarly to the Unix command uniq, filter out elements in a vector that are the same as the preceding value. uniql returns a logical vector that can be used to identify them.

Usage

uniq(x)

uniql(x)

Arguments

x

A vector.

Value

For uniq(), the vector x with adjacent repeated elements removed. For uniql(), a logical vector of length(x).

See also

unfill() to replace adjacent repeated elements.

unique() and duplicated() to find repeated elements regardless of adjacency.

rle() to find lengths of adjacent repeated runs.

Examples

uniq(c(1, 1, 2, 1))
#> [1] 1 2 1
uniql(c(1, 1, 2, 1))
#> [1]  TRUE FALSE  TRUE  TRUE