Create a relationship between two datasets, dataset_1 and dataset_2.
By default, this function establishes a directed relationship with dataset_1 as the parent.
If dataset_2 is not specified, the function creates a primary key for dataset_1.
Arguments
- dataset_1, dataset_2
(
character(1)) Dataset names. Whendataset_2is omitted, a primary key fordataset_1is created.- keys
-
(optionally named
character) Column mapping between the datasets, wherenames(keys)maps columns indataset_1corresponding to columns ofdataset_2given by the elements ofkeys.If unnamed, the same column names are used for both datasets.
If any element of the
keysvector is empty with a non-empty name, then the name is used for both datasets.
- directed
-
(
logical(1)) Flag that indicates whether it should create a parent-child relationship between the datasets.TRUE(default)dataset_1is the parent ofdataset_2;FALSEwhen the relationship is undirected.
Examples
join_key("d1", "d2", c("A"))
#> $d1
#> $d1$d2
#> A
#> "A"
#>
#>
#> attr(,"class")
#> [1] "join_key_set"
#> attr(,"parents")
#> attr(,"parents")$d2
#> [1] "d1"
#>
join_key("d1", "d2", c("A" = "B"))
#> $d1
#> $d1$d2
#> A
#> "B"
#>
#>
#> attr(,"class")
#> [1] "join_key_set"
#> attr(,"parents")
#> attr(,"parents")$d2
#> [1] "d1"
#>
join_key("d1", "d2", c("A" = "B", "C"))
#> $d1
#> $d1$d2
#> A C
#> "B" "C"
#>
#>
#> attr(,"class")
#> [1] "join_key_set"
#> attr(,"parents")
#> attr(,"parents")$d2
#> [1] "d1"
#>