[R] Odp: problem with basic boolean selection in sequence
Petr PIKAL
petr.pikal at precheza.cz
Wed Apr 9 11:43:00 CEST 2008
Hi
Do not use computers, they are full of such traps and do not do what we
think they do.
See FAQ 7.31 Why doesn't R think these numbers are equal
Regards
Petr
petr.pikal at precheza.cz
r-help-bounces at r-project.org napsal dne 09.04.2008 11:32:00:
> Dear R users,
>
> I have a surprising problem while selecting values in a sequence created
> with the seq() function...
> I've tried a lot of test before sending this here and hope I did not
> disturb you for a foolish mistake from me
>
> Please, have a look at the following lines:
> #_______________________________________________________________________
> > test2<-seq(from=0,to=1,by=.1)
> > test2
> [1] 0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
> > test2==1
> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
> > test2==0.9
> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
> > test2==0.8
> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
> > test2==0.7
> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> > test2==0.6
> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> > test2==0.5
> [1] FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
> > test2==0.4
> [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
> > test2==0.3
> [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> > test2==0.2
> [1] FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> > test2==0.1
> [1] FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> > test2==0.0
> [1] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> >
> # there is a problem with values 0.3, 0.6 and 0.7 impossible to select
> in such a vector...
> # the same thing happens with other sequence including somme of these
values
>
> test3<-seq(from=0,to=1,by=0.01)
> test3
> test3==0.3 # not working
> test3==0.6 # working
> test3==0.7 # not working
>
#________________________________________________________________________
>
> Does anyones has an explanation and a solution ?
>
> Kind regards
>
> Ben
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
More information about the R-help
mailing list