[Rd] A different error in sample()

Duncan Murdoch murdoch@dunc@n @ending from gm@il@com
Wed Sep 19 19:57:31 CEST 2018

This may be a doc error or a coding bug.

The help page for sample says:

"Non-integer positive numerical values of n or x will be truncated to 
the next smallest integer, which has to be no larger than 

This is not true:

 > table(sample(2.5, 1000000, replace = TRUE))

      1      2      3
399933 399716 200351

We shouldn't have those 3's if truncation of x had occurred.

Duncan Murdoch

 > sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default

[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1

More information about the R-devel mailing list