bug in sample (PR#305)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
01 Nov 1999 22:58:42 +0100


rgentlem@jimmy.harvard.edu writes:

> The following appears to be a bug in 0.90
> 
> > x<-sample(10,1:4,rep=T)
> > x
> [1] 8
> > ?sample
> >  x<-sample(10,1:4,rep=T)
> > x
> [1] 5
> 
> Of course, I forgot the syntax but I still don't like the result.

Weelll... the code seems to indicate that that is the intended result:
if length(x) == 1  and x>=1, you get samples from 1:x and since size
is non-vectorized, only the 1st element takes and you get samples of
size 1.

Splus3.4 does likewise, although it does give a warning:
  Numerical expression has 4 elements: only the first used...


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._