[R] Returning index of vector element matching specific value

davidwood d.wood at imb.uq.edu.au
Fri Mar 1 04:30:28 CET 2013


Thanks for the reply AK.

>From R FAQ 7.31: "The only numbers that can be represented exactly in R's
numeric type are integers and fractions whose denominator is a power of 2"

I'm not sure though that this is the problem here, does this statement apply
to only floating point numbers?  Is 0.15 a floating point number?

Also the dummy code I provided above works for 0.1, which is 1/10, but not
0.15, which is 3/20, yet neither of these fractions has a denominator that
is a power of 2, of if FAQ 7.31 is to be read literally, neither of these
fractions can be accurately represented yet one still works in the test.

I will cast the vector to character and go on from there - but it would be
great if I could understand this a bit more.

Cheers,
Dave





--
View this message in context: http://r.789695.n4.nabble.com/Returning-index-of-vector-element-matching-specific-value-tp4659952p4659955.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list