[R] seq
Berton Gunter
gunter.berton at gene.com
Fri Sep 3 19:17:04 CEST 2004
> Note however the result of
>
> 0.1*(5:0) == 0.3)
> [1] FALSE FALSE FALSE FALSE FALSE FALSE
>
> as opposed to "==0.5", "==0.4", "==0.2", "==0.1" or "==0"!
>
> I hope this helps,
> Ted.
>
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
> Fax-to-email: +44 (0)870 167 1972
> Date: 03-Sep-04 Time: 13:59:59
At the risk of flailing at a dead and even dessicated horse ...
>From the Help file of identical(), the construction
identical(all.equal(x,y),TRUE) gives the desired test for equality for
finite precision arithmetic. Hence:
> sapply(.1*(0:5),function(x)identical(all.equal(x,.3),TRUE))
[1] FALSE FALSE FALSE TRUE FALSE FALSE
which is, presumably, as desired.
Cheers,
-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
"The business of the statistician is to catalyze the scientific learning
process." - George E. P. Box
More information about the R-help
mailing list