0

I have 2 dataframes, d(date,a,b,c,number1,number2) and e(a,b,c,population) where a,b,c are gender, state and categorie of age.

rem : the number of lines of d > the number of lines of e

I would like to add the good amount of pupulation from e corresponding to the same a and b and c in the dataframe d, ie d(date,a,b,c,number1,number2,population)

What I tried : (didn't work)

result <- merge (d,e,by=c(a,b,c))
Wasp
  • 3
  • 1

1 Answers1

0

Left join:

result <- merge(d, e, by = c("a", "b", "c"), all.x = TRUE)
diaspv
  • 111
  • 8
  • thank you for your answer diaspv, but it gives me a data frame result bigger than the d one. And I would like to have the same number of line (obs) for result and d. – Wasp Jul 29 '20 at 19:31
  • Without a reproducible example it is more difficult to assist you. The relationship between your tables is probably one-to-many. Group the data in the second table to achieve the desired result. – diaspv Jul 29 '20 at 20:15
  • my bad, just realized that my data frame e is wrong, first time working with big files and I didn't check it.. thanks for your support :) – Wasp Jul 29 '20 at 21:03