- 
                Notifications
    You must be signed in to change notification settings 
- Fork 2.1k
Description
Mutate-joins (dplyr) documentation says:
relationship
Handling of the expected relationship between the keys of x and y. If the expectations chosen from the list below are invalidated, an error is thrown.
NULL, the default, doesn't expect there to be any relationship between x and y. However, for equality joins it will check for a many-to-many relationship (which is typically unexpected) and will warn if one occurs, encouraging you to either take a closer look at your inputs or make this relationship explicit by specifying "many-to-many".
See the Many-to-many relationships section for more details.
"one-to-one" expects:
Each row in x matches at most 1 row in y.
Each row in y matches at most 1 row in x.
"one-to-many" expects:
Each row in y matches at most 1 row in x.
"many-to-one" expects:
Each row in x matches at most 1 row in y.
"many-to-many" doesn't perform any relationship checks, but is provided to allow you to be explicit about this relationship if you know it exists.
relationship doesn't handle cases where there are zero matches. For that, see unmatched.
I see there are 2 issues:
- 
one-to-manyandmany-to-onedescription looks awkward and reversed to me. Logically, it should specify from left to right, x -> y. Soone-to-manyshould mean "Rows in x may match multiple rows in y". Similarly,many-to-oneshould mean "Multiple rows in x may match same row in y".
- 
Specifying relationshipexplicitly asone-to-manyormany-to-onedo not generate any warning or error if there is no such matching in the data, i.e. if onlyone-to-oneexists. I would expect an error would be thrown if the specified relationship does not exist in the matching as the documentation says, otherwise I don't get the point of specifying the relationship explicitly.
I have read this but I believe the above issues still remain to be resolved.