How to sort elements (select elements randomly) from a vector?

5

How can I sort elements (select elements randomly) from a vector in R ? For example, I want to sort elements of this vector:

numeros = c(1,2,45,63,29,100,999,23.45,76.1)
    
asked by anonymous 17.12.2015 / 14:12

1 answer

4

To sort, for example, ten values of the concerned vector in a pseudo-random fashion, you can do the following:

numeros <- c(1,2,45,63,29,100,999,23.45,76.1)
sample(numeros,size=10, replace=TRUE)

Note: replace=TRUE to allow replicates and replace=FALSE otherwise.

    
17.12.2015 / 14:19