# ------------------- # Data set # ------------------- mydata=read.table(textConnection(" V1 V2 V3 1 15 10 4 2 6 4 7 3 10 5 2 4 8 6 6"),header=TRUE) closeAllConnections() # ------------------- # Regression models # ------------------- # Combinations library(forward) comb=t(fwd.combn(colnames(mydata),2)) # Summariesres=apply(comb,1,function(x){ y1=mydata[,x[1]] x1=mydata[,x[2]] m=lm(y1~x1) summary(m) } ) names(res)= apply(comb,1,paste,collapse="/",sep=" ") # Output in an external file sink("E:/out.txt") res sink()