[R] "which" is wrong?

From: Troels Ring <tring_at_gvdnet.dk>
Date: Sun 27 Mar 2005 - 02:42:33 EST


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



R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sun Mar 27 02:48:24 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:56 EST