[R] collapse a list of dataframes

dan wang wangdan412 at gmail.com
Mon Feb 2 22:09:43 CET 2015


How about this,

t <- lapply(a,function(x){colnames(x)=c("A","B");return(x)})
do.call(rbind,t)

On Mon, Feb 2, 2015 at 4:00 PM, Tom Wright <tom at maladmin.com> wrote:

> Hi all,
>
> I'm trying to avoid loops (no real reason, just as an exercise).
>
> Given a list:
>
> list(data.frame(a=1:3,b=letters[1:3]),data.frame(x=1:5,b=LETTERS[1:5]))
>
> Is there an easy way to collapse this to a single dataframe
>
> result<-data.frame(a=c(1:3,1:5),b=c(letters[1:3],LETTERS[1:5]))
>
>
> Thanks
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list