Re: [R] random value generation in a row

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Wed, 20 Apr 2011 20:14:28 -0400

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

______________________________________________
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.
Received on Thu 21 Apr 2011 - 00:17:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 21 Apr 2011 - 00:50:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive