dm {dm}R Documentation

Data model class

Description

The dm class holds a list of tables and their relationships. It is inspired by datamodelr, and extends the idea by offering operations to access the data in the tables.

dm() creates a dm object from tbl objects (tibbles or lazy data objects).

new_dm() is a low-level constructor that creates a new dm object.

dm_get_con() returns the DBI connection for a dm object. This works only if the tables are stored on a database, otherwise an error is thrown.

dm_get_tables() returns a named list of dplyr tbl objects of a dm object. Filtering expressions are NOT evaluated at this stage. To get a filtered table, use dm_apply_filters_to_tbl(), to apply filters to all tables use dm_apply_filters()

is_dm() returns TRUE if the input is of class dm.

as_dm() coerces objects to the dm class

validate_dm() checks the internal consistency of a dm object.

Usage

dm(..., .name_repair = c("check_unique", "unique", "universal", "minimal"))

new_dm(tables = list())

dm_get_con(x)

dm_get_tables(x)

is_dm(x)

as_dm(x)

validate_dm(x)

Arguments

...

Tables to add to the dm object. If no names are provided, the tables are auto-named.

.name_repair

Options for name repair. Forwarded as repair to vctrs::vec_as_names().

tables

A named list of the tables (tibble-objects, not names), to be included in the dm object.

x

An object.

Details

All lazy tables in a dm object must be stored on the same database server and accessed through the same connection.

Value

For dm(), new_dm(), as_dm(): A dm object.

For dm_get_con(): The DBI::DBIConnection for dm objects.

For dm_get_tables(): A named list with the tables constituting the dm.

For is_dm(): Boolean, is this object a dm.

For validate_dm(): Returns the dm, invisibly, after finishing all checks.

See Also

Examples

dm(trees, mtcars)
new_dm(list(trees = trees, mtcars = mtcars))
as_dm(list(trees = trees, mtcars = mtcars))


dm_nycflights13()$airports
dm_nycflights13() %>% names()

copy_dm_to(
  dbplyr::src_memdb(),
  dm_nycflights13()
) %>%
  dm_get_con()

dm_nycflights13() %>% dm_get_tables()
dm_nycflights13() %>% dm_get_filters()
dm_nycflights13() %>% validate_dm()
is_dm(dm_nycflights13())
dm_nycflights13()["airports"]
dm_nycflights13()[["airports"]]
dm_nycflights13()$airports


[Package dm version 0.2.8 Index]