[R] Inconsistency using seq

R. Michael Weylandt <michael.weylandt@gmail.com> michael.weylandt at gmail.com
Mon Jun 18 22:54:16 CEST 2012


No, this is rather the nature of floating point calculations. 

You may perhaps be looking for ?all.equal or R FAQ 7.31 (I think that's the one) which is google-able. It's a complicated subject, but those should get you started. 

Best,
Michael

On Jun 18, 2012, at 2:58 PM, hamoreno <hamoreno at asu.edu> wrote:

> 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() ?
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Inconsistency-using-seq-tp4633739.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org 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.



More information about the R-help mailing list