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

Bert Gunter gunter.berton at gene.com
Wed Aug 15 18:23:00 CEST 2012


Define: "Absolutely random";  "systematic differences"

(All pseudorandom numbers are by definition generated by a
deterministic algorithm from a possibly random starting seed set).

On Wed, Aug 15, 2012 at 9:11 AM,  <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?
No.

-- Bert

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



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list