[R] How can I generate a random order?

jim holtman jholtman at gmail.com
Wed Nov 12 21:30:21 CET 2008


sample(100)

On Wed, Nov 12, 2008 at 3:24 PM, Stuart Leask
<Stuart.Leask at nottingham.ac.uk> wrote:
> Feeling very stupid here.
>
> I just want to randomly-ordered some integers, e.g. the numbers 1 to
> 100, with each element present once only in a random order.
> I suspect I need to randomly sample a population 1-100, remove that
> number, then randomly sample what is left until they've all gone,  but I
> can't seem to find the right combination of order/sort/sample + runif.
>
> I fear it can't be that hard - has anyone cracked this?
>
> Stuart
>
> Dr Stuart J Leask DM MRCPsych MA BChir
> Clinical Senior Lecturer and Honorary Consultant in Clinical Psychiatry
> University Dept of Psychiatry, A Floor, Queen's Medical Centre,
> Nottingham. NG7 2UH
> www: Google "Dr Stuart Leask"
>
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses, which could damage your computer system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list