Using the seq function, and then substituting into R that does not produce the desired results

When writing the following code in R:

seq1 <- seq(from = 0.05, to = 0.5, by = 0.05)

and then run the following code:

seq1 == 0.15

I get the following output:

FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

Ideally, I should get:

 FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

The funny thing is if I say:

seq1 == (0.1+0.05)

Then I get the desired result:

FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE

What could be the problem?

+4
source share

Source: https://habr.com/ru/post/1648380/


All Articles