[R] Bug in "seq" (or a "feature") ?

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Mon Aug 10 23:40:33 CEST 2009


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of Tal Galili
> Sent: Monday, August 10, 2009 2:14 PM
> To: r-help at r-project.org
> Subject: [R] Bug in "seq" (or a "feature") ?
> 
> (I use R 2.9.1 with win XP)
> 
> If I run this code:
> seq(-0.1,.9, by = .05)[seq(-0.1,.9, by = .05) <= 0.5]
> I get this output:
> [1] -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45
> Why is 0.50 not in the results ?
> (It seems that it gives a slightly bigger number then 0.5 but I don't
> understand why it does that)
> 
> 
> Where as if I try:
> seq(-0.1,.9, by = .05)[seq(-0.1,.9, by = .05) <= 0.4]
> and get:
> [1] -0.10 -0.05 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40
> Then 0.40 WILL be in the results.
> 
> Thanks,Tal
> 
> 

This is another question for which the answer is FAQ 7.31.  

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA  98504-5204
 




More information about the R-help mailing list