Document expected cardinality

Current dplyr joins support a relationship argument. If each row in the left table should match at most one row in the right table, declare many-to-one. Check unmatched keys separately; a cardinality assertion does not establish that every expected match exists.

Keep the failed example

When an assertion fails, preserve a minimal synthetic example and clarify the key. Do not remove the check just to complete the pipeline. Repeated subject identifiers may be legitimate when the real key also includes a visit or parameter.

Illustrative example

dplyr::left_join(
  labs, subjects,
  by = "USUBJID",
  relationship = "many-to-one"
)

Review and test this example against your own inputs and specification before use.

Sources & further reading

Sources checked 20 September 2026. Implementation commentary reflects a practical review perspective; source material may change.

Have a related programming or implementation challenge?

Discuss it with Sai ↗