[R] Comparison conditionals when extracting from data.frame not working reliably
mviljamaa at kapsi.fi
Fri Sep 9 14:11:40 CEST 2016
I’m getting strange behaviour when trying to extract rows from a two-column data.frame with double values.
My data looks like:
1 121.11750 65
2 89.36188 98
3 115.44320 85
4 99.44964 83
and I’m testing extracting rows that have mom_iq at some interval, so e.g.
kidmomiq[kidmomiq$mom_iq > 80.0 && kidmomiq$mom_iq < 130.0,]
correctly returns rows that have mom_iq \in ]80.0, 130.0[.
However, if I adjust this to:
kidmomiq[kidmomiq$mom_iq > 80.0 && kidmomiq$mom_iq < 120.0,]
(and there are clearly values that also fall \in ]80.0, 120.0[ !)
 mom_iq kid_score
<0 rows> (or 0-length row.names)
Why does the extraction fail on some values, but not some others?
More information about the R-help