[Rd] Trouble with ifelse and if statement (PR#7962)

Gabor Grothendieck ggrothendieck at gmail.com
Wed Jun 22 14:13:56 CEST 2005


On 6/22/05, Martin Maechler <maechler at stat.math.ethz.ch> wrote:
> 
>       <........nonsense non-bug report by Woolton........>
> 
>    Marc> This is not a bug and yes you have missed something.
> 
>    Marc> Read R FAQ 7.31 Why doesn't R think these numbers are equal?
> 
>    Marc> More information is also available here:
> 
>    Marc> http://grouper.ieee.org/groups/754/
> 
> thank you, Marc.
> 
>    Marc> One possible solution:
> 
>    >> i
>    Marc> [1] 0.08 0.00 0.33 0.00 0.00 0.00 0.00 0.33 0.00 0.00 0.08 0.08 0.20
>    Marc> [14] 0.00 0.13
> 
> Note that a slightly more recommended way for the following is
> 
>  as.integer(sapply(i, function(x) isTRUE(all.equal(x, 0.33))))
> 
> using the    isTRUE(all.equal(...))  idiom
> which I'd recommend quite generally.

Perhaps it should be added to the 7.31 FAQ answer.



More information about the R-devel mailing list