Bug 15819 - options(OutDec) and summary.lm
Summary: options(OutDec) and summary.lm
Status: CLOSED INVALID
Alias: None
Product: R
Classification: Unclassified
Component: Analyses (show other bugs)
Version: R 3.1.0
Hardware: Other Linux
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-06-04 11:08 UTC by Allan Sims
Modified: 2014-06-09 20:42 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 Allan Sims 2014-06-04 11:08:30 UTC
x=runif(10)
y=runif(10)
options(OutDec=",")
summary(lm(y~x))

## result is:

Call:
lm(formula = y ~ x)

Residuals:
     Min       1Q   Median       3Q      Max 
-0,27788 -0,09671 -0,02772  0,16458  0,27650 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)   0,8721     0,1522   5,731 0,000439 ***
x            -0,7404     0,2353  -3,147 0,013654 *  
---
Signif. codes:  0 ‘***’ 0,001 ‘**’ 0,01 ‘*’ 0,05 ‘.’ 0,1 ‘ ’ 1

Residual standard error: 0,1995 on 8 degrees of freedom
Multiple R-squared:  0.5532,	Adjusted R-squared:  0.4974 
F-statistic: 9.905 on 1 and 8 DF,  p-value: 0,01365

## 

Most decimal marks are commas (as expected), but there are still some periods as decimal marks:
Multiple R-squared:  0.5532
Adjusted R-squared:  0.4974 
F-statistic: 9.905
Comment 1 Brian Ripley 2014-06-09 08:29:50 UTC
This is because that conversion is by formatC, which is not affected by getOption('OutDec') (see its help).

We can perhaps change this one, but there will be quite a few instances.
Comment 2 Martin Maechler 2014-06-09 19:22:28 UTC
Yes, you are right about the result.
OutDec  only influences R's own internal printing routines.

However, high level  print() methods, such as the 
stats:::print.summary.lm  used here,  or many other print() routines in packages
will not obey to 'OutDec'  if they use either   sprintf()  or   formatC()
as these use  C's  formatting facilities directly.

I would argue that forbidding the use of sprintf() or formatC() in print()
methods is too harsh...

But thank you for bringing the issue up!
Comment 3 Brian Ripley 2014-06-09 20:42:02 UTC
This and some instances of using formatC in print methods have been changed in R-devel to make use of getOption("OutDec').  But it does not happen automatically if print methods use formatC or sprintf.