Skip to content
Prev 167570 / 398502 Next

Converting rankings to paired-comparisons

one way is:

x <- matrix(c(10,20,30,40,0,
     10,10,10,10,50,
     30,30,30,5,5), nrow=3, ncol=5, byrow=TRUE,
     dimnames = list(1:3, letters[1:5])
)

ind <- combn(ncol(x), 2)
out <- apply(ind, 2, function (i) as.numeric(x[, i[1]] >= x[, i[2]]))
colnames(out) <- apply(ind, 2, function (i, nams)
     paste(nams[i[1]], nams[i[2]], sep = ""), nams = colnames(x))
out


I hope it helps.

Best,
Dimitris
Iuri Gavronski wrote: