sfsmisc (version 1.1-5)

uniqueL: A Reversable Version of unique()

Description

A version of unique keeping enough information to reverse (or invert) to the original data.

Usage

uniqueL(x, isuniq = !duplicated(x), need.sort = is.unsorted(x))

Arguments

x

numeric vector, of length n, say.

isuniq

logical vector of the same length as x. For the reversion to work this should select at least all unique values of x.

need.sort

logical indicating if x is not yet sorted. Note that this argument exists only for speedup possibility when it is known, and that it must be set correctly.

Value

list of two components,

ix

integer vector of indices

xU

vector of values from x

such that both x[isuniq] === xU and xU[ix] === x.

See Also

Duplicated from the sfsmisc package in addition to the standard unique and duplicated.

Examples

Run this code
# NOT RUN {
 x0 <- c(1:3,2:7,8:4)
 str(r0 <- uniqueL(x0))
 with(r0, xU[ix]) ## == x0 !
# }

Run the code above in your browser using DataCamp Workspace