[R] seq() question
Marc Schwartz
marc_schwartz at comcast.net
Sat Sep 29 05:19:51 CEST 2007
On Fri, 2007-09-28 at 21:58 -0500, Derek Ogle wrote:
> 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.
See R FAQ 7.31 Why doesn't R think these numbers are equal?
http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
HTH,
Marc Schwartz
More information about the R-help
mailing list