[R] create new column to combine 2 data.frames

PIKAL Petr petr.pikal at precheza.cz
Fri Aug 30 11:03:10 CEST 2013


Hi

see ?merge

something like 

merge(df1, df2)

Petr

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Mat
> Sent: Friday, August 30, 2013 10:37 AM
> To: r-help at r-project.org
> Subject: [R] create new column to combine 2 data.frames
> 
> Hello together i have a little problem with the combine of two
> data.frames.
> 
> I have 2 data.frames, which look like this one:
> 
> first dataframe:
> ID Name
> 1  Jack
> 2  John
> 3  Jill
> 
> second dataframe
> ID  Days  Type
> 1    3       Training
> 2    1       Management
> 3    4       Training
> 
> At the end i want to create a data.frame like this one (the Type should
> be the new column and the entry of the column should be the days):
> 
> ID Name  Training    Management
> 1  Jack    3            0
> 2  John    0            1
> 3  Jill       4            0
> 
> maybe anyone can help me, how i can do this.
> 
> Thanks a lot.
> 
> Best regards. Mat
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/create-new-
> column-to-combine-2-data-frames-tp4674963.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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.



More information about the R-help mailing list