[R] merge 2 data.frames in dependence of 2 values

William Dunlap wdunlap at tibco.com
Thu Nov 13 18:59:57 CET 2014


merge(df1, df2, all=TRUE)


Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Thu, Nov 13, 2014 at 6:02 AM, Matthias Weber <
Matthias.Weber at fntsoftware.com> wrote:

> Hello togehter,
>
> i have a little problem. Maybe anyone can help me.
>
> I have 2 data.frames, which look like as follows:
> First:
>
>         NAME    MONTH     BONUS
> 1      Andy     2014-10       100
> 2      Pete     2014-10        200
> 3      Marc    2014-10        300
> 4      Andy    2014-11        400
>
> Second:
>
>       NAME  MONTH    BONUS_2
> 1    Andy    2014-10       150
> 2    Pete     2014-11       180
> 3    Jason   2014-10       190
> 4    Paul     2014-10       210
> 5    Andy    2014-11       30
>
> How can I merge this 2 data.frames, if I want the following result:
>
>         NAME    MONTH     BONUS    BONUS_2
> 1     Andy     2014-10       100            150
> 2     Pete     2014-11                         180
> 3     Marc    2014-10        300
> 4     Andy    2014-11       400             30
> 5     Pete     2014-10       200
> 6     Jason  2014-10                         190
> 7     Paul     2014-10                         210
>
> The important thing is, that for every accordance in the Columns "NAME"
> and "MONTH" I get a new line.
>
> Thanks for your help.
>
> Best regards.
>
> Mat
>
> ________________________________
> This e-mail may contain trade secrets, privileged, undisclosed or
> otherwise confidential information. If you have received this e-mail in
> error, you are hereby notified that any review, copying or distribution of
> it is strictly prohibited. Please inform us immediately and destroy the
> original transmittal. Thank you for your cooperation.
>
> Diese E-Mail kann Betriebs- oder Geschaeftsgeheimnisse oder sonstige
> vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtuemlich
> erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine
> Vervielfaeltigung oder Weitergabe der E-Mail ausdruecklich untersagt. Bitte
> benachrichtigen Sie uns und vernichten Sie die empfangene E-Mail. Vielen
> Dank.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list