Thank you all for helping me out. As Michael points out, I abused the rounding and formatting of print() while debugging. The default number of digits to print is 7 according to ?print.default, which makes floating point numbers to be somewhat plausible for index vector subsetting at first glance: ------------------------------------------ > print(0.000000000001) [1] 1e-12 > print(0.999999999999) [1] 1 ------------------------------------------ However, since ?[ mentioned that numerics are coerced to integers in fact, it turns out to be an floating point issue. As Berend and Rui noted, it can be revealed by: ------------------------------------------ > print(0.000000000001, digits = 17) [1] 9.9999999999999998e-13 > print(formatC(0.000000000001, format="f", 17)) [1] "0.00000000000100000" > print(0.999999999999, digits = 17) [1] 0.99999999999900002 > print(formatC(0.999999999999, format="f", 17)) [1] "0.99999999999900002" ------------------------------------------ As we can see above, floating point number is a miracle, and there is still some magic with print(). :) BTW, I think this is a general issue, which should be carefully considered regardless of R or other languages. Have a nice day.
Cheers, Guo [[alternative HTML version deleted]] ______________________________________________ R-help@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.