test<-read.table('/Users/zzhang4/Desktop/test.txt') test<-t(test) i1<-seq(1,34,2) i2<-seq(2,34,2) dset<-cbind(test[i1,1], test[i2,1],test[i1,2], test[i2,2],test[i1,3], test[i2,3]) dset1<-cbind(rbind(dset[,1:2], dset[,3:4],dset[,5:6]), rep(1:3, each=17), rep(c(rep(0,9),rep(1,8)),3)) dset1<-cbind(dset1[,2], dset1[,1]-dset1[,2], dset1[,3:4]) m1<-glm(dset1[, 1:2]~factor(dset1[,3])+dset1[,4], family=binomial("logit")) === data === {{:lab:zzhang:consultant:test.txt}}