Skip to content
Prev 200090 / 398503 Next

why the same values cannot be judged to be the same in R

On Nov 12, 2009, at 10:04 PM, rusers.sh wrote:

            
I suspect your use of multiple logical tests across two different  
dataframes with different numbers of rows may not be giving you the  
results you expect:
 > data_1$x1==data2$x1
[1] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
 > data_1$y1==data2$y1
[1] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE
 > data2$tag==0
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE  # So that test is doing  
nothing

 > data2$y1
[1] 1.32 2.34 1.37 2.35 3.33 3.35 1.31 1.33

 > data_1$y1
[1] 2.34 2.35

Perhaps you ought to look at the dyadic function %in% as a substitute  
for "=="

?"%in%"
If the above commentary did not clarify what was happening, then can  
you explain in more detail what (and why) you were doing at each step  
and what you expected to get in the end. The phrase "two same  
observations between data_1 and data2" does not seem to be an  
unambiguous expression. I cannot think of any natural ordering to  
these rows of cases, so the notion of "between" does not seem  
appropriate.