Description Usage Arguments Value Note Examples
View source: R/varray_helper_functions.R
For a permutation of a set of integers 1, 2, ...,p
, finds the
inverse permutation using the which
function.
1 | invert.perm(perm)
|
perm |
Vector of integers in |
A vector of length length(perm)
of the inverse permutation.
This function won't check whether the integers you input are
in the set {1:length(perm)}
, but allows for length-0 entry.
1 2 3 4 5 6 7 | perm <- c(5, 1, 2, 3, 4)
(perminv <- invert.perm(perm))
perm[perminv]
perminv[perm]
## The zero case:
invert.perm(integer(0))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.