check_join: Check Join

Description Usage Arguments Value See Also Examples

Description

Checks that the columns in data frame x form a many-to-one join with the corresponding columns in y, ie, the join is a unique key in y and all the rows in x have a match in y.

Usage

1
2
check_join(x, y, by = NULL, all_y = FALSE, x_name = substitute(x),
  y_name = substitute(y), error = TRUE)

Arguments

x

The object to check.

y

The parent data frame.

by

A character vector or named character vector of the columns to join by.

all_y

A flag indicating whether all the rows in y should have a match in x.

x_name

A string of the name of the object x.

y_name

A string of the name of the object y.

error

A flag indicating whether to throw an informative error or immediately generate an informative message if the check fails.

Value

An invisible copy of x (if it doesn't throw an error).

See Also

check_data

Examples

1
2
3
4
data1 <- data.frame(x = 1:2)
data2 <- data.frame(x = 3:5, y = 2L)
check_join(data1, data2, error = FALSE)
check_join(data1, data2, by = c(x = "y"), error = FALSE)

Example output

Warning message:
join between data1 and data2 must include all the rows in data1 
Warning messages:
1: column 'y' in data2 must be a unique key 
2: join between data1 and data2 must include all the rows in data1 

checkr documentation built on May 1, 2019, 6:59 p.m.