Learn R Programming

dm (version 0.0.4.9001)

dm: 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 one or multiple tbl objects (tibbles or lazy data objects).

dm_from_src() creates a dm from some or all tables in a src (a database or an environment).

new_dm() doesn't perform any checks on the input. You may need to double-check the returned object with validate_dm().

All constructors create an empty dm if called without arguments.

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

cdm_get_src() returns the dplyr source component of a dm object.

cdm_get_con() returns the connection object (con-part of dplyr source component) of a dm object.

cdm_get_tables() returns a named list with dplyr tbl objects of a dm object. The filter expressions are NOT evaluated at this stage. To get the filtered tables, use tbl.dm()

cdm_get_filter() returns the filter component of a dm object, the set filter expressions.

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

as_dm() coerces objects to the dm class

Usage

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

dm_from_src(src, table_names = NULL)

new_dm(tables = list())

validate_dm(x)

cdm_get_src(x)

cdm_get_con(x)

cdm_get_tables(x)

cdm_get_filter(x)

is_dm(x)

as_dm(x)

Arguments

...

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

.name_repair

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

src

A dplyr table source object.

table_names

A character vector of the names of the tables to include.

tables

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

x

An object.

See Also

Examples

Run this code
# NOT RUN {
library(dplyr)
dm(iris, mtcars)
dm_from_src(dplyr::src_df(pkg = "nycflights13"))
new_dm(list(iris = iris, mtcars = mtcars))
as_dm(list(iris = iris, mtcars = mtcars))

cdm_nycflights13() %>% tbl("airports")
cdm_nycflights13() %>% src_tbls()
cdm_nycflights13() %>% cdm_get_src()
cdm_nycflights13() %>% cdm_get_tables()

cdm_nycflights13() %>%
  cdm_rename_tbl(ap = airports)
cdm_nycflights13() %>%
  cdm_rename_tbl(ap = airports, fl = flights)
# }

Run the code above in your browser using DataLab