https://github.com/hadley/dplyr
Raw File
Tip revision: 98b8a0f5de25e238ac97514da24ec228610c8701 authored by Lionel Henry on 19 January 2021, 09:23:23 UTC
Merge pull request #5686 from lionel-/fix-warning-overhead
Tip revision: 98b8a0f
setops.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sets.r
\name{setops}
\alias{setops}
\alias{union_all}
\title{Set operations}
\usage{
union_all(x, y, ...)
}
\arguments{
\item{x, y}{objects to perform set function on (ignoring order)}

\item{...}{other arguments passed on to methods}
}
\description{
These functions override the set functions provided in base to make them
generic so that efficient versions for data frames and other tables can be
provided. The default methods call the base versions. Beware that
\code{intersect()}, \code{union()} and \code{setdiff()} remove duplicates.
}
\examples{
mtcars$model <- rownames(mtcars)
first <- mtcars[1:20, ]
second <- mtcars[10:32, ]

intersect(first, second)
union(first, second)
setdiff(first, second)
setdiff(second, first)

union_all(first, second)
setequal(mtcars, mtcars[32:1, ])

# Handling of duplicates:
a <- data.frame(column = c(1:10, 10))
b <- data.frame(column = c(1:5, 5))

# intersection is 1 to 5, duplicates removed (5)
intersect(a, b)

# union is 1 to 10, duplicates removed (5 and 10)
union(a, b)

# set difference, duplicates removed (10)
setdiff(a, b)

# union all does not remove duplicates
union_all(a, b)
}
back to top