[R] numeric comparison error

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Mon Jun 18 23:58:53 CEST 2018


FAQ 7.31.

Binary arithmetic.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Jun 18, 2018 at 2:45 PM, Brian Smith <bsmith030465 using gmail.com> wrote:

> Hi,
>
> I am a little bit perplexed at why I am getting some values as FALSE:
>
> > cpgbins <- seq(0,1,0.05)
>
> > cpgbins
>  [1] 0.00 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65
> 0.70 0.75 0.80 0.85 0.90 0.95 1.00
>
> > cpgbins[1] == 0.00
> [1] TRUE
> > cpgbins[2] == 0.05
> [1] TRUE
> > cpgbins[3] == 0.10
> [1] TRUE
> > cpgbins[4] == 0.15
> [1] FALSE
> > cpgbins[5] == 0.20
> [1] TRUE
> > cpgbins[6] == 0.25
> [1] TRUE
> > cpgbins[7] == 0.30
> [1] FALSE
>
> > class(cpgbins)
> [1] "numeric"
>
> > class(cpgbins[7])
> [1] "numeric"
>
> What is the cause for this?
>
> thanks!!
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]




More information about the R-help mailing list