[R] Logical Indexing of vectors -- Odd Behavior or....
white.denis@epamail.epa.gov
white.denis at epamail.epa.gov
Thu Mar 27 22:32:49 CET 2003
Notice that
> seq (.1, .9, by=.1)[3] - 0.3
[1] 5.551115e-17
See the thread "[R] round() seems inconsistent when rounding 5s" about
March 16 on the same issue, inexact representation.
> R-Community,
>
> I'm puzzled by the following behavior in R 1.6.2 and have found no
> reference to this in the archives:
>
> >P <- seq(.1,.9,by=.1)
>
> >P[P > .4]
> [1] 0.5 0.6 0.7 0.8 0.9
> as expected. However,
> >P[P > .3]
> [1] 0.3 0.4 0.5 0.6 0.7 0.8 0.9
> ???
> Which is unexpected. Furthermore on the logical side
> > P>.1
> [1] FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> > P>.2
> [1] FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> > P>.3
> [1] FALSE FALSE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> > P>.4
> [1] FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE
> > P>.5
> [1] FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE TRUE
> > P>.6
> [1] FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE
> > P>.7
> [1] FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE TRUE
>
>
> What's with .3 and .7? Any pointers to where I might find out the info
> would be greatly appreciated,
>
> I'm running 1.6.2 on windows XP,
> Sincerely,
>
More information about the R-help
mailing list