I have two dataframes of customer locations. One is a master dataframe called all_customer_locations. However, because we occasionally get new customers with new locations, we also have a new_locations dataframe.
I want to join these dataframes together only IF the new_locations has new data. I've already written code to make sure that the new locations are unique, but what I'm stumped on is writing code to say if the rows in new_locations is 0, don't join it with all_customer_locations.
This is the code that I have now:
library(dplyr)
if(nrow(new_locations > 0)) {
full_join(all_customer_locations, new_locations, by = "city_state_country")
}
Error in matrix(if (is.null(value)) logical() else value, nrow = nr, dimnames = list(rn, :
length of 'dimnames' [2] not equal to array extent
It's important that I don't join these if there are no new values, otherwise R views all other columns as logicals instead of numeric and throws an error when I try to coalesce the columns.
Thank you!
Aucun commentaire:
Enregistrer un commentaire