|
31 | 31 | The terms \emph{join-to} and \emph{join-from} indicate which in a pair of tables is the "baseline" or "authoritative" source -- this governs the ordering of rows and columns. |
32 | 32 | Whether each refers to the "left" or "right" table of a pair depends on the \code{how} argument: |
33 | 33 | \enumerate{ |
34 | | - \item{ \code{how \%in\% c("left", "semi", "anti")}: \emph{join-to} is \emph{RHS}, \emph{join-from} is \emph{LHS}. } |
35 | | - \item{ \code{how \%in\% c("inner", "full", "cross")}: \emph{LHS} and \emph{RHS} tables are treated equally, so that the terms are interchangeable. } |
36 | | - \item{ \code{how == "right"}: \emph{join-to} is \emph{LHS}, \emph{join-from} is \emph{RHS}. } |
| 34 | + \item \code{how \%in\% c("left", "semi", "anti")}: \emph{join-to} is \emph{RHS}, \emph{join-from} is \emph{LHS}. |
| 35 | + \item \code{how \%in\% c("inner", "full", "cross")}: \emph{LHS} and \emph{RHS} tables are treated equally, so that the terms are interchangeable. |
| 36 | + \item \code{how == "right"}: \emph{join-to} is \emph{LHS}, \emph{join-from} is \emph{RHS}. |
37 | 37 | } |
38 | 38 |
|
39 | 39 | Using \code{mult="error"} will throw an error when multiple rows in \emph{join-to} table match to the row in \emph{join-from} table. It should not be used just to detect duplicates, which might not have matching row, and thus would silently be missed. |
40 | 40 |
|
41 | 41 | When not specified, \code{mult} takes its default depending on the \code{how} argument: |
42 | 42 | \enumerate{ |
43 | | - \item{ When \code{how \%in\% c("left", "inner", "full", "right")}, \code{mult="error"}. } |
44 | | - \item{ When \code{how \%in\% c("semi", "anti")}, \code{mult="last"}, although this is equivalent to \code{mult="first"}. } |
45 | | - \item{ When \code{how == "cross"}, \code{mult="all"}. } |
| 43 | + \item When \code{how \%in\% c("left", "inner", "full", "right")}, \code{mult="error"}. |
| 44 | + \item When \code{how \%in\% c("semi", "anti")}, \code{mult="last"}, although this is equivalent to \code{mult="first"}. |
| 45 | + \item When \code{how == "cross"}, \code{mult="all"}. |
46 | 46 | } |
47 | 47 |
|
48 | 48 | When the \code{on} argument is missing, it will be determined based \code{how} argument: |
49 | 49 | \enumerate{ |
50 | | - \item{ When \code{how \%in\% c("left", right", "semi", "anti")}, \code{on} becomes the key column(s) of the \emph{join-to} table. } |
51 | | - \item{ When \code{how \%in\% c("inner", full")}, if only one table has a key, then this key is used; if both tables have keys, then \code{on = intersect(key(lhs), key(rhs))}, having its order aligned to shorter key. } |
| 50 | + \item When \code{how \%in\% c("left", right", "semi", "anti")}, \code{on} becomes the key column(s) of the \emph{join-to} table. |
| 51 | + \item When \code{how \%in\% c("inner", full")}, if only one table has a key, then this key is used; if both tables have keys, then \code{on = intersect(key(lhs), key(rhs))}, having its order aligned to shorter key. |
52 | 52 | } |
53 | 53 |
|
54 | 54 | When joining tables that are not directly linked to a single table, e.g. a snowflake schema (see References), a \emph{right} outer join can be used to optimize the sequence of merges, see Examples. |
|
0 commit comments