I came across something new that I've never done before and I'm hoping to get some help. I'm trying to join two data sets (easy enough job), but there are only partial-string matches in two of the columns. I tried to use fuzzy_join, but I can't get it to work for me. Below is what I'm trying to do. I'm hoping to end up with the data frame called df_final. Any ideas?
df1 <- tribble(
~student_id, ~course, ~grade,
"001", "social studies grade", "A",
"001", "ela grade", "A",
"001", "math grade", "A",
"002", "social studies grade", "B",
"002", "ela grade", "B",
"002", "math grade", "B",
"003", "social studies grade", "C",
"003", "ela grade", "C",
"003", "math grade", "C",
"004", "social studies grade", "C",
"004", "ela grade", "C",
"004", "math grade", "C",
"005", "social studies grade", "C",
"005", "ela grade", "C",
"005", "math grade", "C",
)
df2 <- tribble(
~student_id, ~course,
"001", "5th Social Studies",
"001", "5th ELA",
"001", "5th Mathematics",
"002", "6th Social Studies",
"002", "6th ELA",
"002", "6th Mathematics",
"003", "8th Social Studies",
"003", "8th ELA",
"003", "8th Mathematics",
)
df_final <- tribble(
~student_id, ~course, ~grade,
"001", "5th Social Studies", "A",
"001", "5th ELA", "A",
"001", "5th Mathematics", "A",
"002", "6th Social Studies", "B",
"002", "6th ELA", "B",
"002", "6th Mathematics", "B",
"003", "8th Social Studies", "C",
"003", "8th ELA", "C",
"003", "8th Mathematics", "C"
)