[R] Combining multiple dataframes in a list

Nash morrison at ibms.sinica.edu.tw
Sat Mar 28 14:25:39 CET 2009


## hi, you can try this.

m<- list(fc=data.frame(A=1:3, B=2:4)) 
frame=do.call(cbind, m) 
colnames(frame)<-substr(names(frame),4,4)
frame



On Fri, 27 Mar 2009 13:08:18 +0800, Daren Tan wrote
> I have a list containing multiple dataframes. Depending on whether 
> the dataframes have 1 column or more than 1 columns, the column 
> names are named differently. How can I force single column 
> dataframes to have prefixed column names ?
> 
> > m<- list(fc=data.frame(A=1:3))
> > do.call(cbind, m)
>   A
> 1 1
> 2 2
> 3 3
> 
> > m<- list(fc=data.frame(A=1:3, B=2:4))
> > do.call(cbind, m)
>   fc.A fc.B
> 1    1    2
> 2    2    3
> 3    3    4
> 
> ______________________________________________
> R-help at 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.


--
Nash - morrison at ibms.sinica.edu.tw




More information about the R-help mailing list