randperm.RdGenerates a random permutation.
randperm(a, k)Generates one random permutation of k of the elements a, if
a is a vector, or of 1:a if a is a single integer.
Vector of permuted elements of a or 1:a.
This behavior is different from Matlab/Octave, but does better correspond with the behavior of the perms() function.
randperm(1:6, 3)
#> [1] 3 2 5
randperm(6, 6)
#> [1] 5 3 2 4 6 1
randperm(11:20, 5)
#> [1] 13 20 15 11 17
randperm(seq(2, 10, by=2))
#> [1] 4 10 2 8 6