If I have understood correctly, then as an example for 4 columns how about .... d=data.frame(C1=c(1,1,1,1,1),C2=c(2,2,2,2,2),C3=c(3,3,3,3,3),C4=c(4,4,4,4,4)) combs=combn(paste("C",seq_len(4),sep=""),2,simplify=FALSE) one = sapply(combs,function(x) d[x[1]]) two = sapply(combs,function(x) d[x[2]]) ret = mapply(cbind,one,two) colnames(ret) = paste("C",1:length(combs),sep="") You will need to change seq_len(4) to seq_len(269) in the second line. HTH Pete -- View this message in context: http://r.789695.n4.nabble.com/expression-for-index-of-pairwise-combinations-tp3263025p3298495.html Sent from the R help mailing list archive at Nabble.com.