aTest <- data.frame(AccountNumber = c("10001", "20002", "40004"), ServiceProvider = c("Jabo Gas and Electric", "Java Coffee", "Java Coffee"), DBID = c("001", "002", "003")) bTest <-data.frame(AccountNumber = c("10001", "20002", "30003", "40004"), Installation = c("Base A", "Base B", "Base C", "Base D"), ProviderID = c("H12", "J02", "K03", "L09")) # Outer join: merge(x = aTest, y = bTest, by = "AcountNumber", all = TRUE) # # > merge(x = aTest, y = bTest, by = "AccountNumber", all = TRUE) # AccountNumber ServiceProvider DBID Installation ProviderID # 1 10001 Jabo Gas and Electric 001 Base A H12 # 2 20002 Java Coffee 002 Base B J02 # 3 40004 Java Coffee 003 Base D L09 # 4 30003 Base C K03 # # Left outer: merge(x = aTest, y = bTest, by = "AcountNumber", all.x = TRUE) # # > merge(x = aTest, y = bTest, by = "AccountNumber", all.x = TRUE) # AccountNumber ServiceProvider DBID Installation ProviderID # 1 10001 Jabo Gas and Electric 001 Base A H12 # 2 20002 Java Coffee 002 Base B J02 # 3 40004 Java Coffee 003 Base D L09 # # Right outer: merge(x = aTest, y = bTest, by = "AcountNumber", all.y = TRUE) # # > merge(x = aTest, y = bTest, by = "AccountNumber", all.y = TRUE) # AccountNumber ServiceProvider DBID Installation ProviderID # 1 10001 Jabo Gas and Electric 001 Base A H12 # 2 20002 Java Coffee 002 Base B J02 # 3 40004 Java Coffee 003 Base D L09 # 4 30003 Base C K03 # # Cross join: merge(x = aTest, y = bTest, by = NULL) # # > merge(x = aTest, y = bTest, by = NULL) # AccountNumber.x ServiceProvider DBID AccountNumber.y Installation ProviderID # 1 10001 Jabo Gas and Electric 001 10001 Base A H12 # 2 20002 Java Coffee 002 10001 Base A H12 # 3 40004 Java Coffee 003 10001 Base A H12 # 4 10001 Jabo Gas and Electric 001 20002 Base B J02 # 5 20002 Java Coffee 002 20002 Base B J02 # 6 40004 Java Coffee 003 20002 Base B J02 # 7 10001 Jabo Gas and Electric 001 30003 Base C K03 # 8 20002 Java Coffee 002 30003 Base C K03 # 9 40004 Java Coffee 003 30003 Base C K03 # 10 10001 Jabo Gas and Electric 001 40004 Base D L09 # 11 20002 Java Coffee 002 40004 Base D L09 # 12 40004 Java Coffee 003 40004 Base D L09