[R] R minimal calculation error

Marc Schwartz marc_schwartz at me.com
Fri Aug 24 14:45:09 CEST 2012


On Aug 24, 2012, at 5:48 AM, Frederik Bertling <Frederik.Bertling at stud.uni-due.de> wrote:

> Hi,
> 
> I'm doing some easy calculations to normalize some values. This looks like
> this:
> 
> x=mean(a+b+c+d ...)
> a=a-x
> b=b-x
> c=c-x
> d=d-x
> ...
> mean(a+b+c+d ...) ---> Should now be 0!
> However, I'm getting results like -2.315223e-18
> This is really near to 0 but not very aesthetic.
> 
> Can I prevent this? Or is this behaviour desired?
> Thank you very much!
> Burtan



Read this:

 http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

Regards,

Marc Schwartz




More information about the R-help mailing list