Learn R Programming

joinspy (version 0.7.3)

detect_cardinality: Detect Join Relationship Type

Description

Determines the actual cardinality relationship between two tables.

Usage

detect_cardinality(x, y, by)

Value

Character string: "1:1", "1:m", "m:1", or "m:m".

Arguments

x

A data frame (left table).

y

A data frame (right table).

by

Column names to join by.

See Also

join_strict(), join_spy()

Examples

Run this code
# 1:1 relationship
x <- data.frame(id = 1:3, val = 1:3)
y <- data.frame(id = 1:3, name = c("A", "B", "C"))
detect_cardinality(x, y, "id")

# 1:m relationship
x <- data.frame(id = 1:3, val = 1:3)
y <- data.frame(id = c(1, 1, 2, 3), name = c("A1", "A2", "B", "C"))
detect_cardinality(x, y, "id")

Run the code above in your browser using DataLab