[R] Inconsistency using seq

Milan Bouchet-Valat nalimilan at club.fr
Mon Jun 18 22:51:23 CEST 2012


Le lundi 18 juin 2012 à 12:58 -0700, hamoreno a écrit :
> Hi all,
> 
> Is there any problem of precision when using seq?. For example:
> 
> x<- seq(0,4,0.1)
> x[4]=0.3
> 
> BUT:
> 
> x[4]-0.3=5.551115e-17
> 
> It means when I use this condition within an if clause, it does not find
> values with 0.3 for x[4] as it is not precisely 0.3.
> Is there any bug in seq() ?
No. Have a look at the FAQ:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f


Cheers



More information about the R-help mailing list