Skip to content

Add a symmetric difference set function #4811

@felipegerard

Description

@felipegerard

I often have the need to find elements (rows) that two vectors (data frames) don't have in common. Finding these elements using setops is straightforward, but I wonder if it would be ok to add the symmetric difference (aka. union \ intersection) function to save a few key strokes. Below is my proposed solution. I can make the PR if we agree it makes sense to add this.

symdiff <- function(x, y) {
  setdiff(union(x, y), intersect(x, y))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementtables 🧮joins and set operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions