powered by
The inverse function to which creates a logical vector/matrix from indices.
which
Unwhich(idx, n, useNames = TRUE)
the indices as returned by which.
integer, the length of the original vector.
logical, determining if the names of the indices should be preserved.
a logical vector of the length n, with TRUE on the positions i.
TRUE
i
https://stackoverflow.com/questions/7659833/inverse-of-which
# NOT RUN { ll <- c(TRUE, FALSE, TRUE, NA, FALSE, FALSE, TRUE) names(ll) <- letters[seq(ll)] i <- which(ll) # back again (loosing the names of the FALSEs) Unwhich(i, length(ll)) # }
Run the code above in your browser using DataLab