0

I have two dfs that need to be merged. DF 1 contains 120 rows each with an email. DF2 contains identical emails that are either missing, or duplicated as DF2 is a repeated measures data set where measurement was taken for once a day over a period of 10 days (10 rows per person at max-- but it varies because of missing data or non completion).

DF1:
Email             x1 x2 x3 ...
john@gmail.com..
stacy@gmail.com..
winston@gmail.com ..

DF2
Email             y1 y2 y3
john@gmail.com
john@gmail.com
john@gmail.com
john@gmail.com
stacy@gmail.com
stacy@gmail.com
winston@gmail.com
winston@gmail.com
winston@gmail.com
winston@gmail.com
winston@gmail.com
.. up to 10 entries 

I need to merge the two and have DF1 duplicate itself over each email so I can make a long form dataset. What merge function should I be using here? I want to keep both x1 x2 x3 and y1 y2 y3. Would this be a full join?

D500
  • 442
  • 5
  • 17
  • You'll make it easier for others to help if you provide your data in a way that someone can simply copy it into their R: e.g., dput(head(DF1, n = 15)). The package dplyr provides a nice set of join functions: e.g, left_join(). – ssp3nc3r Oct 06 '17 at 17:01
  • `dplyr::left_join(DF2, DF1, by = "Email")` – markdly Oct 06 '17 at 17:13

0 Answers0