[Solved] Fill data frame with data from another data frame where columns do not match [closed]


Using dplyr from the tidyverse you should be able to do this:

library(tidyverse)
AB <-
   B %>%
   rename(ID = `Cust No`, Name = `Customer Name`) %>%
   full_join(A, ., by = "ID")

rename will let you change the names in B manually so that they match A in the form new_name = old_name. full_join will keep all rows in both data frames and placing A as the first argument and B (represented as the .) as the second argument will put the columns in A first. by = ensures you’re matching by the column ID.

solved Fill data frame with data from another data frame where columns do not match [closed]