powered by
TRUE
This function is basically an inverse of which.
which
unwhich(which, n)
A logical vector of length n whose elements listed in which are set to TRUE, and whose other elements are set to FALSE.
n
FALSE
a numeric vector of indices to set to TRUE.
total length of the output vector.
x <- as.logical(rbinom(10,1,0.5)) stopifnot(all(x == unwhich(which(x), 10)))
Run the code above in your browser using DataLab