-5

Supposing I have the vector

x <- c(1,2,3,4,5,6)

Is there any way I could randomly mix its elements?

Or create a vector which would have integer elements from 1 to 6 which do not repeat?

talat
  • 68,970
  • 21
  • 126
  • 157
  • 3
    [First hit](http://stackoverflow.com/questions/13765972/how-to-randomize-a-vector) when googling your title. "This question does not show any research effort". – Henrik Aug 17 '16 at 11:55

1 Answers1

5

We need sample to do that

sample(x)

If it needs to be repeated, use the replicated

replicate(3, sample(x))
akrun
  • 874,273
  • 37
  • 540
  • 662