[R] sample

R. Michael Weylandt michael.weylandt at gmail.com
Sat Oct 6 18:10:05 CEST 2012

Yes and no. Same effect, but you won't get the same random numbers
because -- I believe -- a different algorithm is used. grep the source
for sample and sample2 if you're interested.


On Sat, Oct 6, 2012 at 5:02 PM, solafah bh <solafahbh at yahoo.com> wrote:
> Hello
> If I have x=c(3,2,6,1) and n=length(x), are the following codes equivalent??
> sample(x,1,replace=TRUE)    and       sample(x,1,replace=TRUE,prob=rep(1/n , n) )
> Regards
>         [[alternative HTML version deleted]]
> ______________________________________________
> 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.

More information about the R-help mailing list