[R] sample function

Liaw, Andy andy_liaw at merck.com
Fri Mar 11 04:05:15 CET 2005


It's not the simulated data, but how hist() handled it.  If you use
truehist() in the MASS package, you don't see the problem.  Nor would you
see it like this:

> table(temp)/length(temp)
temp
     0      1      2      3      4      5      6      7      8      9     10
11 
0.0745 0.0745 0.0830 0.0755 0.0760 0.0750 0.0700 0.0765 0.0775 0.0805 0.0830
0.0765 
    12 
0.0775 

Andy

> From: mirage sell
> 
> Hi everyone, I need help.
> I want to have a "uniform" kind distribution. When I used 
> sample function I 
> got almost twice many zeros compared to other numbers. What's 
> wrong with my 
> command ?
> 
> temp <-sample(0:12, 2000, replace=T,prob=(rep(1/13,13)))
> hist(temp)
> 
> Thanks in advance,
> 
> Taka,
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
> 
> 
>




More information about the R-help mailing list