[R] precision in seq
Eric.Elguero at mpl.ird.fr
Tue Feb 5 13:21:54 CET 2008
thank you to all who answered.
+ 0.05+0.05+0.05+0.05+0.05+0.05 - 0.95
> seq(0,1,0.05) - 0.95
> 0+19*0.05 - 0.95
so this is the way seq calculates. I would have guessed
that addition was more accurate than multiplication,
but that is not the case.
this one however bothers me:
I noticed this problem when I tried to extract rows of a matrix
according to whether values of some vector where in the set
(0,0.05,...,0.95,1), with something like x%in%seq(0,1,0.05)
Now I understand that I should not use this construction
unless x is of type integer. Would you agree?
More information about the R-help