[R] seq() question

Derek Ogle DOgle at northland.edu
Sat Sep 29 04:58:23 CEST 2007


Hello all,

I am attempting to use the seq() function to define breaks for the cut() function but am finding performance that I do not understand.  The root of my problem appears to be contained in the following simple example.

> brks <- seq(0.8,1.2,0.1)
> brks
[1] 0.8 0.9 1.0 1.1 1.2
> brks==1.2
[1] FALSE FALSE FALSE FALSE FALSE
> brks==1.1
[1] FALSE FALSE FALSE  TRUE FALSE

The last value in the sequence does not appear to be equal to its apparent value (i.e., 1.2) whereas the fourth value in the sequence, for example, does (e.g., 1.1).

Any help/suggestions with the concept or "trick" that I am missing here?  Thank you in advance.

p.s., I am using R 2.5.1 with ...

> Sys.info()
                      sysname                       release 
                    "Windows"                      "NT 5.1" 
                      version                      nodename 
"(build 2600) Service Pack 2"                  "CSE229-001" 
                      machine
                        "x86"



More information about the R-help mailing list