A join of a desired type is performed between table_1 and table_2. The two tables need to be directly connected by a foreign key relation. Since this function is a wrapper around dm_flatten_to_tbl(), the LHS of the join will always be a "child table", i.e. a table referencing the other table.

dm_join_to_tbl(dm, table_1, table_2, join = left_join)

Arguments

dm

A dm object.

table_1

One of the tables involved in the join.

table_2

The second table of the join.

join

The type of join to be performed, see dplyr::join().

Value

The resulting table of the join.

See also

Other flattening functions: dm_flatten_to_tbl()

Examples

dm_join_to_tbl(dm_nycflights13(), airports, flights)
#> # A tibble: 11,227 x 26 #> year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time #> <int> <int> <int> <int> <int> <dbl> <int> <int> #> 1 2013 1 10 3 2359 4 426 437 #> 2 2013 1 10 16 2359 17 447 444 #> 3 2013 1 10 450 500 -10 634 648 #> 4 2013 1 10 520 525 -5 813 820 #> 5 2013 1 10 530 530 0 824 829 #> 6 2013 1 10 531 540 -9 832 850 #> 7 2013 1 10 535 540 -5 1015 1017 #> 8 2013 1 10 546 600 -14 645 709 #> 9 2013 1 10 549 600 -11 652 724 #> 10 2013 1 10 550 600 -10 649 703 #> # … with 11,217 more rows, and 18 more variables: arr_delay <dbl>, #> # carrier <chr>, flight <int>, tailnum <chr>, origin <chr>, dest <chr>, #> # air_time <dbl>, distance <dbl>, hour <dbl>, minute <dbl>, time_hour <dttm>, #> # name <chr>, lat <dbl>, lon <dbl>, alt <dbl>, tz <dbl>, dst <chr>, #> # tzone <chr>
# same result is achieved with: dm_join_to_tbl(dm_nycflights13(), flights, airports)
#> # A tibble: 11,227 x 26 #> year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time #> <int> <int> <int> <int> <int> <dbl> <int> <int> #> 1 2013 1 10 3 2359 4 426 437 #> 2 2013 1 10 16 2359 17 447 444 #> 3 2013 1 10 450 500 -10 634 648 #> 4 2013 1 10 520 525 -5 813 820 #> 5 2013 1 10 530 530 0 824 829 #> 6 2013 1 10 531 540 -9 832 850 #> 7 2013 1 10 535 540 -5 1015 1017 #> 8 2013 1 10 546 600 -14 645 709 #> 9 2013 1 10 549 600 -11 652 724 #> 10 2013 1 10 550 600 -10 649 703 #> # … with 11,217 more rows, and 18 more variables: arr_delay <dbl>, #> # carrier <chr>, flight <int>, tailnum <chr>, origin <chr>, dest <chr>, #> # air_time <dbl>, distance <dbl>, hour <dbl>, minute <dbl>, time_hour <dttm>, #> # name <chr>, lat <dbl>, lon <dbl>, alt <dbl>, tz <dbl>, dst <chr>, #> # tzone <chr>
# this gives an error, because the tables are not directly linked to each other: try(dm_join_to_tbl(dm_nycflights13(), airlines, airports))
#> Error : Tables `airlines` and `airports` are not directly linked by a foreign key relation.