function for counting discordant pairs is not working

Viewed 179

I am trying to count the number of discordant pairs. For example:

arg1=c("b","c","a","d")
arg2 = c("b","c","d","a")

There is 1 discordant pair in the above (the pair: "a" and "d")

But when I run:

require(asbio)
sum(ConDis.matrix(arg1,arg2)==-1,na.rm=TRUE)

The answer I receive is: 5 (instead of the correct answer - 1)

I also tried:

require(RankAggreg)
require(DescTools)
xy <- table(arg1,arg2)
cd <- ConDisPairs(xy)
cd$D

the answer is 5 again.

What am I missing?

2 Answers
Related