Adds one or more new tables to a dm. Existing tables are not overwritten.

dm_add_tbl(dm, ..., repair = "unique", quiet = FALSE)

Arguments

dm

A dm object.

...

One or more tables to add to the dm. If no explicit name is given, the name of the expression is used.

repair

Either a string or a function. If a string, it must be one of "check_unique", "minimal", "unique", or "universal". If a function, it is invoked with a vector of minimal names and must return minimal names, otherwise an error is thrown.

  • Minimal names are never NULL or NA. When an element doesn't have a name, its minimal name is an empty string.

  • Unique names are unique. A suffix is appended to duplicate names to make them unique.

  • Universal names are unique and syntactic, meaning that you can safely use the names as variables without causing a syntax error.

The "check_unique" option doesn't perform any name repair. Instead, an error is raised if the names don't suit the "unique" criteria.

quiet

By default, the user is informed of any renaming caused by repairing the names. This only concerns unique and universal repairing. Set quiet to TRUE to silence the messages.

Value

The initial dm with the additional table(s).

See also

Examples

dm() %>% dm_add_tbl(mtcars, flowers = iris)
#> ── Metadata ──────────────────────────────────────────────────────────────────── #> Tables: `mtcars`, `flowers` #> Columns: 16 #> Primary keys: 0 #> Foreign keys: 0
# renaming table names if necessary (depending on the `repair` argument) dm() %>% dm_add_tbl(new_tbl = mtcars, new_tbl = iris)
#> New names: #> * new_tbl -> new_tbl...1 #> * new_tbl -> new_tbl...2
#> ── Metadata ──────────────────────────────────────────────────────────────────── #> Tables: `new_tbl...1`, `new_tbl...2` #> Columns: 16 #> Primary keys: 0 #> Foreign keys: 0