Skip to contents

Select values from a data.frame df matching any column from another data.frame or a selection of row indices. If a second data frame and a selection of rows is provided, values from df matching any value in df2[rows, ] are returned. If only rows indices are provided, rows matching any value in df[rows, ] are returned. NAs are not matched.

This is a wrapper around dplyr::filter with if_any for the case where the value should be in a reference set, with the option to choose whether to use another data frame or a subset of rows as the reference.

Usage

filter_by_union(df, df2 = NULL, rows = NULL, by = NULL)

Arguments

df

A data.frame from which to select matching rows

df2

Optional, a second data frame

rows

Row indices for subsetting, either df2 if present or df

by

= columns to select from df2