Re: [R] getting random integers

2010-04-30 Thread Hans Ekbrand
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(100, min = 1, max = 10))) Thank for this advice, apparently 1 and 10 had not the same chances of being selected. > I'd

Re: [R] getting random integers

2010-04-29 Thread Erik Iverson
Hans Ekbrand wrote: I want 100 integers. Each integer, x, can be in the range 1 =< x => 10. Does the following code give 1 and 10 the same chances to be selected as 2:8? round(runif(100, min = 1, max = 10)) If you just want to sample integers, use ?sample __

Re: [R] getting random integers

2010-04-29 Thread Sarah Goslee
You can always take a look. If you use a much bigger sample size it will be obvious: hist(round(runif(100, min = 1, max = 10))) I'd use instead: hist(sample(1:10, 100, replace=TRUE)) Sarah On Thu, Apr 29, 2010 at 12:39 PM, Hans Ekbrand wrote: > I want 100 integers. Each integer, x,

[R] getting random integers

2010-04-29 Thread Hans Ekbrand
I want 100 integers. Each integer, x, can be in the range 1 =< x => 10. Does the following code give 1 and 10 the same chances to be selected as 2:8? round(runif(100, min = 1, max = 10)) -- Hans Ekbrand signature.asc Description: Digital signature __