[R] Merging two data.frames

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Mon Dec 8 22:38:24 CET 2014


On Mon, 8 Dec 2014, David Lambert wrote:

> I have 2 data frames, M1[n,20] and M2[m,30].

What does this mean? It might be intended to convey matrix dimensions, but 
these are not matrices and that is not R syntax.

> If V1 and V2 are the same in both M1 and M2, then append V3-V30 from M2 onto M1.

What does this mean? V3 is a default column label for data frames, but 
to just refer to V3 suggests an entire column, which doesn't make sense. 
If you mean individual values in the matching row, then where do you plan 
to put 27 values into M1?

> Otherwise, continue searching for a match.
> M1 is complete for all V1 and V2.  M2 is missing observations for V1 or V2, or both.
> I can't figure this one out, except with reference to my old fortran-era skills.  Help!
> 	[[alternative HTML version deleted]]

This desperately needs a reproducible example with a few matches and 
non-matches.  Of course, if you email R code using HTML format it will 
likely get corrupted along the way, which is why the Posting Guide asks 
you to post in PLAIN TEXT format.

> ______________________________________________
> 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.

Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                       Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k

More information about the R-help mailing list