0

Suposse I have tow data frames, df_1:

name     id     x1     x2
Juan D   1     450     2
Jose M   3     300     3
Pedro D  4     500     7
Mateo M  9     200     0

And df_2:

name_1       x3     x4
Juan D       M      zenfone
Pedro D      M      Asus
Mateo M      M      Apple

I want to merge the columns by matching the name to get this:

name     id   x1   x2   x3     x4
Juan D    1  450   2    M      zenfone
Pedro D   4  500   4    M      Asus
Mateo M   9  200   9    M      Apple
Moses
  • 157
  • 1
  • 1
  • 8
  • 1
    do you want answers in python or R? The merge or inner_join function in R will do what you want – morgan121 Feb 20 '19 at 02:54
  • Try with `dplyr::inner_join(df_1, df_2, by = "name")` in `R` – akrun Feb 20 '19 at 02:56
  • @RAB either of the two options would serve me, I tried both without coming up with an efficient solution – Moses Feb 20 '19 at 02:56
  • @akrun I am getting this error `Error: by can't contain join column name which is missing from RHS` I forgot that the name column is not the same col name in df_2, I will fix that on the question – Moses Feb 20 '19 at 03:00
  • 1
    The `by = c("name" = "name_1"))` – akrun Feb 20 '19 at 03:03

0 Answers0