1
$\begingroup$

If you try to calculate the difference between (9.1 - 8.9) - (6.9-6.7) in R, you'll get

> (9.1 - 8.9) - (6.9-6.7)
[1] -8.881784e-16

I found this when I was trying to calculate ranks considering ties as average rank but I saw that because of precision issue, it don't consider the tie.

A <- c( 6.1, 5.5, 8.9, 7.4, 4.3, 9.7, 6.7, 9.4)
B <- c( 7.3, 5.5, 9.1, 7.0, 5.1, 9.8, 6.9, 9.8)
Z <- B - A
rank(abs(Z))
[1] 8.0 1.0 3.0 5.5 7.0 2.0 4.0 5.5

Expected result

[1] 8.0 1.0 3.5 5.5 7.0 2.0 3.5 5.5
$\endgroup$
0
$\begingroup$

What @Stephan Kolassa said.

Round the difference appropriately before ranking

> A <- c( 6.1, 5.5, 8.9, 7.4, 4.3, 9.7, 6.7, 9.4)
> B <- c( 7.3, 5.5, 9.1, 7.0, 5.1, 9.8, 6.9, 9.8)
> Z <- round(B - A, 5)
> rank(abs(Z))
[1] 8.0 1.0 3.5 5.5 7.0 2.0 3.5 5.5
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.