[R] sample() from (un-)sorted vectors

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Aug 15 18:24:00 CEST 2012


This seems more theoretical than specific to R, so you should discuss this question in a more theoretical forum such as http://stats.stackexchange.com/.

FWIW I believe the results will be equally random either way. That doesn't say either way will be "absolutely" random, since I don't think such a thing is possible.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

saschaview at gmail.com wrote:

>Hello,
>
>Vector y is an alphabetically sorted version of vector x. Will both 
>samples, X and Y, be "absolutely" random or will they have systematic 
>differences? And: Should I sort or shuffle a vector before sampling?
>
>Thank you, *S*
>
>x <- as.factor(LETTERS[sequence(10:1)])
>y <- sort(x)
>X <- sample(x, 5)
>Y <- sample(y, 5)
>
>
>-- 
>Sascha Vieweg, saschaview at gmail.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