Skip to contents

A version of sample() which does not treat positive scalar integer x differently. See example.

Usage

shuffle(x, n = length(x), ...)

Arguments

x

(vector())
Vector to sample elements from.

n

(integer())
Number of elements to sample.

...

(any)
Arguments passed down to base::sample.int().

Examples

x = 2:3
sample(x)
#> [1] 3 2
shuffle(x)
#> [1] 2 3

x = 3
sample(x)
#> [1] 1 3 2
shuffle(x)
#> [1] 3