dm (version 0.0.3.9003)

dm: Data model class

Description

The dm class wraps dplyr::src and adds a description of table relationships based on datamodelr::datamodelr-package.

dm() coerces its inputs. If called without parameters, an empty dm object is created.

new_dm() only checks if the inputs are of the correct class. If called without parameters, an empty dm object is created.

validate_dm() checks consistency between the dplyr source and the datamodelr based specification of table relationships. This function is currently a no-op.

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_data_model() returns the datamodelr data model component of a dm object.

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(src, data_model = NULL)

new_dm(tables, data_model)

validate_dm(x)

cdm_get_src(x)

cdm_get_con(x)

cdm_get_tables(x)

cdm_get_data_model(x)

cdm_get_filter(x)

is_dm(x)

as_dm(x)

Arguments

src

A dplyr table source object.

data_model

A datamodelr data model object, or NULL.

tables

A 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(dplyr::src_df(pkg = "nycflights13"))
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 DataCamp Workspace