fyshuffle: Fisher-Yates shuffle

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Function to shuffle vectors according to the Fisher-Yates procedure

Usage

1

Arguments

x

Vector containing the sequence which needs to be shuffled. This vector can be of any type and it is allowed to have one element.

Details

Other than the sample function fyshuffle treats a single value as a vector with one element and will therefore return this element as the shuffled version of the original vector (which are similar).

Value

A randomized version of the input vector.

Author(s)

Reinder Radersma

References

Durstenfeld (1964) Communications of the ACM 7(7):420

See Also

sample

Examples

1
2
3
4
5
x <- 1:10
fyshuffle(x)

y <- c("a","b","c","d","e","f")
fyshuffle(y)

Example output

 [1]  6  9  3  1  5 10  2  4  8  7
[1] "a" "b" "f" "e" "d" "c"

fgpt documentation built on May 1, 2019, 9:45 p.m.