0

I have the following data frame named df1:

CITY V1 V2
A 2 0
B 6 4
C 9 2
D 8 2
E 9 5

And also I have the following dataframe named df2:

CITY X
C 45
E 9

How can I add the information from df2 to df1 based on city name? The desired outcome is:

CITY V1 V2 X
A 2 0 NA
B 6 4 NA
C 9 2 45
D 8 2 NA
E 9 5 9
Tazz
  • 81
  • 9
  • 1
    Please check the `left_join` function from the `tidyverse` package. Or the `merge` function frmo base R. – deschen Dec 09 '20 at 10:22
  • 1
    Does this answer your question? [How to join (merge) data frames (inner, outer, left, right)](https://stackoverflow.com/questions/1299871/how-to-join-merge-data-frames-inner-outer-left-right) – Roman Dec 09 '20 at 10:29

0 Answers0