Skip to content
Prev 105862 / 398506 Next

how to sort random numbers according to the sample ?

in your example you need

r <- matrix(runif(12), 4, 3)
x <- c(6, 8, 9, 11)
########
apply(r, 2, function(y) x[order(y)])


however, you can directly use sample(), i.e.,

sapply(1:3, function(i) sample(x))


I hope it helps.

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
      http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Jenny persson <jenny197806 at yahoo.se>:
Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm