merge | R Documentation |
Merge two dbi.table
s. The dbi.table
method is similar
to the data.table
method except that the result
set is only determined up to row order and is not sorted by default.
Default merge columns: if x
has a foreign key constraint that
references y
then the columns comprising this key are used; see
details. When a foreign key cannot be found, then the common columns
between the two dbi.tables
s are used.
Use the by
, by.x
, and by.y
arguments explicitly to
override this default.
## S3 method for class 'dbi.table'
merge(
x,
y,
by = NULL,
by.x = NULL,
by.y = NULL,
all = FALSE,
all.x = all,
all.y = all,
sort = FALSE,
suffixes = c(".x", ".y"),
no.dups = TRUE,
recursive = FALSE,
...
)
x , y |
|
by |
A vector of shared column names in |
by.x , by.y |
character vectors of column names in |
all |
a logical value. |
all.x |
a logical value. When |
all.y |
a logical value. Analogous to |
sort |
a logical value. Currently ignored. |
suffixes |
a length-2 character vector. The suffixes to be used for making
non- |
no.dups |
a logical value. When |
recursive |
a logical value. Only used when |
... |
additional arguments are ignored. |
Foreign key constraints. Foreign keys can only be queried when (1) the
dbi.table
's schema is loaded, and (2) dbi.table
understands
the underlying database's information schema.
merge.dbi.table
uses sql.join
to join x
and
y
then formats the result set to match the typical merge
output.
a dbi.table
.
chinook <- dbi.catalog(chinook.duckdb)
#The Album table has a foreign key constriant that references Artist
merge(chinook$main$Album, chinook$main$Artist)
#When y is omitted, x's foreign key relationship is used to determine y
merge(chinook$main$Album)
#Multiple foreign keys are supported
csql(merge(chinook$main$Track))
#Track references Album but not Artist, Album references Artist
#This dbi.table includes Artist.Name as well
csql(merge(chinook$main$Track, recursive = TRUE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.