Skip to contents

Shorthand to shuffle a vector and save

Usage

vector_shuffle(., replace = FALSE, prob = NULL, seed = NULL)

Arguments

.

vector to shuffle

replace

replace selected value

prob

probability of occurrence

seed

apply seed if indicated for reproducibility

Value

shuffled vector of items store to the vector name

Examples

v1<-c(3,45,23,3,2,4,1)


#demonstrate vector_shuffle
vector_shuffle(v1)
v1 # show outputs
#> [1]  2 23  4  3  1 45  3

#demonstrate reproducibility in shuffle with seed
v0<-v1
vector_shuffle(v0)
v0 #first output
#> [1]  3  2 23  3  1  4 45

v0<-v1
vector_shuffle(v0)
v0 # different output from first output top
#> [1] 23  2  3 45  1  3  4

v0<-v1
vector_shuffle(v0,seed = 232L)
v0 #second output
#> [1]  4  1 45  3  2 23  3

v0<-v1
vector_shuffle(v0,seed = 232L)
v0 #the same output as second output top
#> [1]  4  1 45  3  2 23  3