Learn R Programming

fuzzyjoin (version 0.1.8)

regex_join: Join two tables based on a regular expression in one column matching the other

Description

Join a table with a string column by a regular expression column in another table

Usage

regex_join(x, y, by = NULL, mode = "inner", ignore_case = FALSE)

regex_inner_join(x, y, by = NULL, ignore_case = FALSE)

regex_left_join(x, y, by = NULL, ignore_case = FALSE)

regex_right_join(x, y, by = NULL, ignore_case = FALSE)

regex_full_join(x, y, by = NULL, ignore_case = FALSE)

regex_semi_join(x, y, by = NULL, ignore_case = FALSE)

regex_anti_join(x, y, by = NULL, ignore_case = FALSE)

Arguments

x

A tbl

y

A tbl

by

Columns by which to join the two tables

mode

One of "inner", "left", "right", "full" "semi", or "anti"

ignore_case

Whether to be case insensitive (default no)

See Also

Examples

Run this code

library(dplyr)
if (requireNamespace("ggplot2", quietly = TRUE)) {
  diamonds <- tibble::as_tibble(ggplot2::diamonds)

  d <- tibble::tibble(regex_name = c("^Idea", "mium", "Good"),
                  type = 1:3)

  # When they are inner_joined, only Good<->Good matches
  diamonds %>%
    inner_join(d, by = c(cut = "regex_name"))

  # but we can regex match them
  diamonds %>%
   regex_inner_join(d, by = c(cut = "regex_name"))
}

Run the code above in your browser using DataLab