I have the data frame 'df' and my desired solution 'out'. I am sure there is a more elegant R-way to do it - without a loop.
df = data.frame(a=1:5,b=letters[1:5],c1=1:5,c2=2:6,c3=3:7,c4=4:8) mylist=NULL for(i in 1:4){ myname<-paste("c",i,sep="") mylist[[i]]<-df[c("a","b",myname)] names(mylist[[i]])<-c("a","b","c") } out<-do.call(rbind,mylist) out Thank you! -- Dimitri Liakhovitski ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.