[R] "which" is wrong?

Troels Ring tring at gvdnet.dk
Sat Mar 26 16:42:33 CET 2005


Dear friends,
R 2.0.1 on windows XP:

TOT <-  seq(0.01,1,by=0.01)
  which(TOT==0.06)
# numeric(0)
which(TOT>0.06)
# [1]   6   7   8  etc
which(TOT<0.06)
#[1] 1 2 3 4 5
  TOT[6]
#[1] 0.06
TOT[6]==0.06
#[1] FALSE

but
TOT[5]==0.05
#[1] TRUE
  and
  which(TOT==0.05)
# [1] 5





TOT looks as expected when printed,
0.35 and 0.36 behaves similarly

I have tried on another machine with the same result - wonder what happens 
and whether
this is as expected ?

Best wishes
Troels Ring,
Aalborg, Denmark




More information about the R-help mailing list