[R] Odp: problem with basic boolean selection in sequence

From: Petr PIKAL <petr.pikal_at_precheza.cz>
Date: Wed, 09 Apr 2008 11:43:00 +0200

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.


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. Received on Wed 09 Apr 2008 - 10:54:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 09 Apr 2008 - 12:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive