rdplyrsemi-join

dplyr semi_join Error: `x` and `y` must share the same src, set `copy` = TRUE (may be slow)


I am using dplyr 1.0.6 and R 4.1.0 and I wrote 2 functions as follows:

AllCustomersList <- loadAllCustomersData()

CouldJoinByNationalID <- matchCustomersByNationalCode(AllCustomersList = AllCustomersList)

loadAllCustomersData() returns a list of two data frames, then the matchCustomersByNationalCode tries to execute a semi_join on those two data.frame as follows:

matchCustomersByNationalCode <- function(AllCustomersList) {
  
  FDCustomers <- AllCustomersList$FDCustomers
  Customers <- AllCustomersList$Customers
  
  semi_join(x = FDCustomers, y = Customers, by = c("NationalID" = "NationalCode"), na_matches = "never") %>% 
    pull(NationalID) %>% 
    return()
}

Actully this is just a wrapper for semi_join as matter of naming. But it throughs an error that says :

Error: x and y must share the same src, set copy = TRUE (may be slow).

Run rlang::last_error() to see where the error occurred.

Called from: signal_abort(cnd)

could anyone help with this?


Solution

  • thanks to walter and Martin Gal I tried to make a reproducible example and it worked! So I checked the class of both data.frames and it says those are both data.frames. But I converted them again to data.frame inside the match function and it worked! it is still odd to me but problem solved!