What can cause a “non-unique matches detected” error in an r merge? What can cause a “non-unique matches detected” error in an r merge? r r

What can cause a “non-unique matches detected” error in an r merge?


Use the sp::merge function with the duplicateGeoms argument set to TRUE (if TRUE geometries in x are duplicated if there are multiple matches between records in x and y)

    require(sp)    ?sp::merge    merge(spatial_data, data_frame, by = 'match_column', duplicateGeoms = TRUE)

(I know this question is older, but I came across it while in search for an answer to it myself)


I found this patch. You extract that data from your SP to data frame.

final_merge <- merge(sp_extract,final_merge, by.x = "name", by.y = "name2" ,all.x = TRUE )

Then you merge to your SP and its should work

 sp_merge  <- sp::merge(sp, final_merge , by.x = "name" , by.y = "name", duplicateGeoms = TRUE,no.dups = FALSE )