Bug 17444 - setting options(digits) causes df in t.test to print incorrectly
Summary: setting options(digits) causes df in t.test to print incorrectly
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Analyses (show other bugs)
Version: R 3.4.4
Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2018-07-09 13:35 UTC by jefflaux
Modified: 2018-07-22 18:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description jefflaux 2018-07-09 13:35:00 UTC
If I use options(digits=3) to set the default number of digits in output, the df is printed incorrectly in the output from t.test.  Here is a simple run on a fresh session (note that the first version has df=35, the second lists df=40):  

> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

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

loaded via a namespace (and not attached):
[1] compiler_3.4.4
> set.seed(1)
> t.test(rnorm(36))

        One Sample t-test

data:  rnorm(36)
t = 0.41658, df = 35, p-value = 0.6795
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 -0.2443862  0.3705778
sample estimates:
 mean of x 
0.06309582 

> options(digits=3)
> set.seed(1)
> t.test(rnorm(36))

        One Sample t-test

data:  rnorm(36)
t = 0.4, df = 40, p-value = 0.7
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 -0.244  0.371
sample estimates:
mean of x 
   0.0631
Comment 1 Martin Maechler 2018-07-22 18:15:19 UTC
Thank you for the report.

It's good I had a long list of considerations posted to R core only..
after some hours .. and a night of sleep, it dawned on me :

The solution is to basically replace 

    format(signif(*, digits=dig))

by  format(*, digits=dig)

Committed to R-devel for now ... with a plan to port to   R 3.5.1 patched later