[R] getting random integers

Hans Ekbrand hans at sociologi.cjb.net
Fri Apr 30 09:31:40 CEST 2010


On Thu, Apr 29, 2010 at 12:43:42PM -0400, Sarah Goslee wrote:
> You can always take a look. If you use a much bigger sample size it will be
> obvious:
> 
> hist(round(runif(1000000, min = 1, max = 10)))

Thank for this advice, apparently 1 and 10 had not the same chances of
being selected.


> I'd use instead:
> 
> hist(sample(1:10, 1000000, replace=TRUE))

sample() is what I want, thank you.

-- 
Hans Ekbrand (http://sociologi.cjb.net) <hans at sociologi.cjb.net>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100430/7744319e/attachment.bin>


More information about the R-help mailing list