[R] options(OutDec) etc {was "Strange warning in summary.lm"}

Martin Maechler maechler at stat.math.ethz.ch
Wed Jul 25 11:51:02 CEST 2007


Without going into your details,
I think  options() should NEVER influence what as.numeric() does
(which I think you are indirectly suggesting it should).

In my eyes, using a decimal comma instead of decimal point in
scientific computing is an abomination in itself.

Providing an  option for  *output* is one thing,
but having it influence basic "R engine" functions like
as.numeric(), format(), ...
is an absolute NO!_NO!  for me.
So I am strongly opposed to an 'InDec' option as was mentioned
earlier in this thread.

We could consider adding a 'dec' (or 'decimal.sep')
*argument* to some R functions,
but such an argument must default to "."  rather than yet
another option.

R should remain as *functional* as possible.
==> options() should be used sparingly.

They should only influence printed output at most, not
computations per se. 
Of course I know that this is not strictly possible since the
computations can use textConnection() etc..

Martin Maechler, ETH Zurich
  

>>>>> "OT" == ONKELINX, Thierry <Thierry.ONKELINX at inbo.be>
>>>>>     on Wed, 25 Jul 2007 11:04:43 +0200 writes:

    OT> Dear Peter, Uwe and Brian,
    OT> I've found some more problems with options(OutDec = ",").

    OT> 1) as.numeric yields NA where it shouldn't

    >> z <- c("12", "12,34", "12.34")
    >> options(OutDec = ",")
    >> as.numeric(z)
    OT> [1] 12,00    NA 12,34
    OT> Warning message:
    OT> NAs introduced by coercion in: as.double.default(z) 

    OT> # should result in c(12, 12.34, NA)

    >> options(OutDec = ".")
    >> as.numeric(z)
    OT> [1] 12.00    NA 12.34
    OT> Warning message:
    OT> NAs introduced by coercion in: as.double.default(z) 


    OT> 2) anova yields the same warning as summary

    >> x <- runif(100)
    >> y <- rnorm(100)
    >> options(OutDec = ",")
    >> summary(lm(y~x))

    OT> Call:
    OT> lm(formula = y ~ x)

    OT> Residuals:
    OT> Min       1Q   Median       3Q      Max 
    OT> -2,81744 -0,61680  0,02107  0,66309  2,20599 

    OT> Coefficients:
    OT> Estimate Std. Error t value Pr(>|t|)
    OT> (Intercept) -0,073531   0,195880  -0,375    0,708
    OT> x            0,007519   0,318159   0,024    0,981

    OT> Residual standard error: 0,9795 on 98 degrees of freedom
    OT> Multiple R-Squared: 5.699e-06,  Adjusted R-squared: -0.0102 
    OT> F-statistic: 0.0005585 on 1 and 98 DF,  p-value: 0,9812 

    OT> Warning message:
    OT> NAs introduced by coercion in: as.double.default(Cf[okP]) 
    >> anova(lm(y~x))
    OT> Analysis of Variance Table

    OT> Response: y
    OT> Df Sum Sq Mean Sq F value Pr(>F)
    OT> x          1  0,001   0,001   6e-04 0,9812
    OT> Residuals 98 94,031   0,960               
    OT> Warning message:
    OT> NAs introduced by coercion in: as.double.default(Cf[okP]) 

    OT> Cheers,

    OT> Thierry


    OT> ----------------------------------------------------------------------------
    OT> ir. Thierry Onkelinx
    OT> Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
    OT> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance
    OT> Gaverstraat 4
    OT> 9500 Geraardsbergen
    OT> Belgium
    OT> tel. + 32 54/436 185
    OT> Thierry.Onkelinx at inbo.be
    OT> www.inbo.be 

    OT> Do not put your faith in what statistics say until you have carefully considered what they do not say.  ~William W. Watt
    OT> A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney

 

    >> -----Oorspronkelijk bericht-----
    >> Van: r-help-bounces at stat.math.ethz.ch 
    >> [mailto:r-help-bounces at stat.math.ethz.ch] Namens ONKELINX, Thierry
    >> Verzonden: donderdag 19 juli 2007 13:56
    >> Aan: Peter Dalgaard
    >> CC: r-help at stat.math.ethz.ch; Uwe Ligges
    >> Onderwerp: Re: [R] Strange warning in summary.lm
    >> 
    >> Dear Peter,
    >> 
    >> Here's an example. Notice the warning in the last two lines 
    >> of the summary with options(OutDec = ","). It's not present 
    >> with options(OutDec = ".").
    >> 
    >> Cheers,
    >> 
    >> Thierry
    >> 
    >> > x <- runif(100)
    >> > y <- rnorm(100)
    >> > options(OutDec = ",")
    >> > summary(lm(y~x))
    >> 
    >> Call:
    >> lm(formula = y ~ x)
    >> 
    >> Residuals:
    >> Min        1Q    Median        3Q       Max 
    >> -2,389749 -0,607002  0,006969  0,689535  1,713197 
    >> 
    >> Coefficients:
    >> Estimate Std. Error t value Pr(>|t|)
    >> (Intercept)  0,03397    0,17774   0,191    0,849
    >> x           -0,09219    0,29518  -0,312    0,755
    >> 
    >> Residual standard error: 0,868 on 98 degrees of freedom 
    >> Multiple R-Squared: 0.0009943,  Adjusted R-squared: -0.0092
    >> F-statistic: 0.09754 on 1 and 98 DF,  p-value: 0,7555 
    >> 
    >> Warning message:
    >> NAs introduced by coercion in: as.double.default(Cf[okP]) 
    >> > options(OutDec = ".")
    >> > summary(lm(y~x))
    >> 
    >> Call:
    >> lm(formula = y ~ x)
    >> 
    >> Residuals:
    >> Min        1Q    Median        3Q       Max 
    >> -2.389749 -0.607002  0.006969  0.689535  1.713197 
    >> 
    >> Coefficients:
    >> Estimate Std. Error t value Pr(>|t|)
    >> (Intercept)  0.03397    0.17774   0.191    0.849
    >> x           -0.09219    0.29518  -0.312    0.755
    >> 
    >> Residual standard error: 0.868 on 98 degrees of freedom 
    >> Multiple R-Squared: 0.0009943,  Adjusted R-squared: -0.0092
    >> F-statistic: 0.09754 on 1 and 98 DF,  p-value: 0.7555 
    >> 
    >> 
    >> --------------------------------------------------------------
    >> --------------
    >> ir. Thierry Onkelinx
    >> Instituut voor natuur- en bosonderzoek / Research Institute 
    >> for Nature and Forest
    >> Cel biometrie, methodologie en kwaliteitszorg / Section 
    >> biometrics, methodology and quality assurance
    >> Gaverstraat 4
    >> 9500 Geraardsbergen
    >> Belgium
    >> tel. + 32 54/436 185
    >> Thierry.Onkelinx at inbo.be
    >> www.inbo.be 
    >> 
    >> Do not put your faith in what statistics say until you have 
    >> carefully considered what they do not say.  ~William W. Watt
    >> A statistical analysis, properly conducted, is a delicate 
    >> dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney
    >> 
    >> 
    >> 
    >> > -----Oorspronkelijk bericht-----
    >> > Van: Peter Dalgaard [mailto:P.Dalgaard at biostat.ku.dk] 
    >> > Verzonden: donderdag 19 juli 2007 13:37
    >> > Aan: ONKELINX, Thierry
    >> > CC: Uwe Ligges; r-help at stat.math.ethz.ch
    >> > Onderwerp: Re: [R] Strange warning in summary.lm
    >> > 
    >> > ONKELINX, Thierry wrote:
    >> > > The problem also exists in a clean workspace. But I've found the 
    >> > > troublemaker. I had set options(OutDec = ","). Resetting this to 
    >> > > options(OutDec = ".") solved the problem.
    >> > >
    >> > > Thanks,
    >> > >
    >> > > Thierry
    >> > >   
    >> > Oups. That sounds like there's a bug somewhere. Can you cook 
    >> > up a minimal example which shows the behaviour?
    >> > 
    >> > -- 
    >> >    O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
    >> >   c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
    >> >  (*) \(*) -- University of Copenhagen   Denmark          Ph:  
    >> > (+45) 35327918
    >> > ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: 
    >> > (+45) 35327907
    >> > 
    >> > 
    >> >
    >> 
    >> ______________________________________________
    >> R-help at stat.math.ethz.ch 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.
    >> 

    OT> ______________________________________________
    OT> R-help at stat.math.ethz.ch mailing list
    OT> https://stat.ethz.ch/mailman/listinfo/r-help
    OT> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    OT> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list