From jori@mey@ @ending from gm@il@com  Wed Sep 19 20:18:50 2018
From: jori@mey@ @ending from gm@il@com (Joris Meys)
Date: Wed, 19 Sep 2018 20:18:50 +0200
Subject: [Rd] A different error in sample()
In-Reply-To: <5b6950ce-ac7a-4f6a-da61-8e70d25bb08c@gmail.com>
References: <5b6950ce-ac7a-4f6a-da61-8e70d25bb08c@gmail.com>
Message-ID: <CAO1zAVbHXAz9o7uf98Q5pUm7R8pSHFigAAtQn90FrGdPfqUn1A@mail.gmail.com>

I believe the word "truncated" is causing the confusion. 3 is "the next
smallest integer" following 2.5. But it is not the truncation done by
trunc(). Rewording to "rounding the next smallest integer" would get rid of
that confusion imho.

Cheers
Joris

On Wed, Sep 19, 2018 at 7:57 PM Duncan Murdoch <murdoch.duncan at gmail.com>
wrote:

> 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
> .Machine$integer.max."
>
> 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
> BLAS:
> /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
> LAPACK:
> /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
>
> locale:
> [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
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


-- 
Joris Meys
Statistical consultant

Department of Data Analysis and Mathematical Modelling
Ghent University
Coupure Links 653, B-9000 Gent (Belgium)
<https://maps.google.com/?q=Coupure+links+653,%C2%A0B-9000+Gent,%C2%A0Belgium&entry=gmail&source=g>

-----------
Biowiskundedagen 2017-2018
http://www.biowiskundedagen.ugent.be/

-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]



[Rd] A different error in sample()
Joris Meys