Hi All,
    I'm trying to use the "sample" function within a loop where the
vector being sampled from (the first argument in the function) will
vary in length and composition.  When the vector is down in size to
containing only one element, I run into the "undesired behaviour"
acknowledged in the ?sample help file.  I don't want sample(10,1) to
return a number from within 1:10, but rather I'd just want it to
return 10 every time.

Example):


Actual:
> sample(10,1)
[1] 2
> sample(10,1)
[1] 9
> sample(10,1)
[1] 4


Desired:
> sample(10,1)
[1] 10
> sample(10,1)
[1] 10
> sample(10,1)
[1] 10


Perhaps sample is not the appropriate function.  I dunno.  Any thoughts?

Regards,
Jonathan

______________________________________________
R-help@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.

Reply via email to