Learn R Programming

jwutil (version 1.2.3)

match_multi: Match across columns for multiple lookup values

Description

This provides a succinct way to query a data frame for conditions, which is otherwise very verbose in base R or dplyr

Usage

match_multi(x, cols, table, incomparables = NULL)

Arguments

x

data.frame

cols

character vector of column names to be found in x

table

vector of items to find

incomparables

passed on to the base function match

Value

matrix with same number of rows as x, and a column for each of cols

Examples

Run this code
# NOT RUN {
j <- cars[1:10, ]
match_multi(j, "speed", 7)
match_multi(j, "dist", 22)
match_multi(j, c("speed", "dist"), 10)
match_multi(j, c("speed", "dist"), c(7, 17))
# }

Run the code above in your browser using DataLab