Suppose I have binary vectors and need to compare their similarily with Kappa
function.
library(asbio)
A <- c(0,1,1,1,1,1,0)
B <- c(0,0,1,0,1,0,1)
C <- c(1,0,0,1,1,0,0)
D <- c(1,1,0,0,0,1,1)
E <- c(1,0,0,1,1,0,1)
Kappa(A,B)$ttl_agreement # 42%
How to loop Kappa
function to get table of all possible comparisons?
I would like to get something like this:
A B C D E
A 100 42 - - -
B 42 100 - - -
C - - 100 - -
D - - - 100 -
E - - - - 100
You can use
outer
functionEDIT :
if you prefer a for-loop (I'd suggest to run some tests to see which method is faster), you can use
expand.grid
to generate the combinations and then iterate over them to fill the matrix