-3

How can I join two dataframes in R, both dataframes have a columns of teams. I want to join them to have the matching values and don't duplicate the teams columns. The column with the same values is called Clubs.

1 Answers1

1

you can join different data with the left_join function of the dplyr package

date 1
df <-tibble::tribble(
  ~id, ~mes_spanish,
   1L,      "Enero",
   2L,    "Febrero",
   3L,      "Marzo",
   4L,      "Abril",
   5L,       "Mayo",
   6L,      "Junio",
   7L,      "Julio",
   8L,     "Agosto",
   9L, "Septiembre",
  10L,    "Octubre",
  11L,  "Noviembre",
  12L,  "Diciembre"
  )

date 2 
df2 <- tibble::tribble(
  ~id, ~mes_english,
   1L,    "January",
   2L,   "February",
   3L,      "March",
   4L,      "April",
   5L,        "May",
   6L,       "June",
   7L,       "July",
   8L,     "August",
   9L,  "September",
  10L,    "October",
  11L,   "November",
  12L,   "December"
  )

join date 
data_join <-df |> left_join(df2)

Outputs:

id  mes_spanish mes_english
1   Enero       January
2   Febrero     February
3   Marzo       March
4   Abril       April
5   Mayo        May
6   Junio       June
7   Julio       July
8   Agosto      August
9   Septiembre  September
10  Octubre     October
11  Noviembre   November
12  Diciembre   December