[R] how to randomize a vector

Frede Aakmann Tøgersen FredeA.Togersen at agrsci.dk
Mon Nov 12 08:29:27 CET 2007


Why didn't you do this in R?

> help.search("random sample")
Help files with alias or concept or title matching 'random sample'
using fuzzy matching:



sample(base)            Random Samples and Permutations



Type 'help(FOO, package = PKG)' to inspect entry 'FOO(PKG) TITLE'.
> 

See ?sample, e.g.

> t1 <- rnorm(70000)
> system.time(t2 <- sample(t1,size=length(t1)))
   user  system elapsed 
   0.01    0.00    0.01 


Best regards

Frede Aakmann Tøgersen
Scientist


UNIVERSITY OF AARHUS
Faculty of Agricultural Sciences
Dept. of Genetics and Biotechnology
Blichers Allé 20, P.O. BOX 50
DK-8830 Tjele

Phone:   +45 8999 1900
Direct:  +45 8999 1878

E-mail:  FredeA.Togersen at agrsci.dk
Web:	   http://www.agrsci.org				

This email may contain information that is confidential.
Any use or publication of this email without written permission from Faculty of Agricultural Sciences is not allowed.
If you are not the intended recipient, please notify Faculty of Agricultural Sciences immediately and delete this email.

 

 

> -----Oprindelig meddelelse-----
> Fra: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] På vegne af leffgh
> Sendt: 12. november 2007 07:50
> Til: r-help at r-project.org
> Emne: [R] how to randomize a vector
> 
> 
> I have a vector whose length is nearly 70 thousand.
> I need randomize it for 1000 times .
> for randomizing , I mean ,the elements of the vector remain 
> intact while their order in the vector get changed randomly.
> I have written a function which seems to be able to solve 
> short vectors , but waste  a lot of time when dealing with 
> the the long vector mentioned above.
>  
> --
> View this message in context: 
> http://www.nabble.com/how-to-randomize-a-vector-tf4789292.html
> #a13700770
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 



More information about the R-help mailing list