[R] random value generation in a row

David Winsemius dwinsemius at comcast.net
Thu Apr 21 02:14:28 CEST 2011


On Apr 20, 2011, at 7:30 PM, Rujealous wrote:

> the plan is
>
> i have to create a column with random numbers from 1 to 5 forming a  
> vector
> with 200 numbers.
> these numbers should have the same proportion, like 40 "1", 40  
> ''2'', etc.

So you really want a random permutation of a fixed set of 200 numbers:

sample( rep(1:5,40), 200)

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list