I am looking for help to insert values in one column of a database by comparing to another column in another database that has matching patterns of addresses. Please see below what I mean.
I am using R.
My data:
df1 <- structure(list(Names = c("A", "B", "C"), Address = c("101, 16 Ave NE",
"203, 4 Cross SE", "115, 48 Ave SW")), class = c("tbl_df", "tbl",
"data.frame"), row.names = c(NA, -3L))
Names Address
<chr> <chr>
1 A 101, 16 Ave NE
2 B 203, 4 Cross SE
3 C 115, 48 Ave SW
df2 <- structure(list(ID = c(1415, 2106, 2107), Address = c("101 16 Ave",
"115 48 Ave SW Cresmont", "203 Skyview 4 Cross SE Near Walmart"
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-3L))
ID Address
<dbl> <chr>
1 1415 101 16 Ave
2 2106 115 48 Ave SW Cresmont
3 2107 203 Skyview 4 Cross SE Near Walmart
Desired output:
Names Address ID
<chr> <chr> <dbl>
1 A 101, 16 Ave NE 1415
2 B 203, 4 Cross SE 2107
3 C 115, 48 Ave SW 2106