unwhich {bazar} | R Documentation |
The unwhich
function is a kind of inverse
of the which
function.
unwhich(w, n)
w |
A vector of integers; morally the result of a call to |
n |
integer. The length of the result; morally the length of the
|
A logical vector of length n
.
x1 <- c(TRUE, FALSE, TRUE, TRUE)
x2 <- unwhich(which(x1), length(x1))
identical(x1, x2) # TRUE
w1 <- c(2, 4, 5, 1, 1)
w2 <- which(unwhich(w1, 10))
identical(sort(unique(as.integer(w1))), w2) # TRUE