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)
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)
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.