dm | R Documentation |
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.
If called without arguments, it will create an empty dm
.
If called with arguments, no validation checks will be made to ascertain that
the inputs are of the expected class and internally consistent;
use dm_validate()
to double-check the returned object.
is_dm()
returns TRUE
if the input is of class dm
.
as_dm()
coerces objects to the dm
class
dm(
...,
.name_repair = c("check_unique", "unique", "universal", "minimal"),
.quiet = FALSE
)
new_dm(tables = list())
is_dm(x)
as_dm(x, ...)
... |
Tables or existing |
.name_repair , .quiet |
Options for name repair.
Forwarded as |
tables |
A named list of the tables (tibble-objects, not names),
to be included in the |
x |
An object. |
For dm()
, new_dm()
, as_dm()
: A dm
object.
For is_dm()
: A scalar logical, TRUE
if is this object is a dm
.
dm_from_con()
for connecting to all tables in a database
and importing the primary and foreign keys
dm_get_tables()
for returning a list of tables
dm_add_pk()
and dm_add_fk()
for adding primary and foreign keys
copy_dm_to()
for DB interaction
dm_draw()
for visualization
dm_flatten_to_tbl()
for flattening
dm_filter()
for filtering
dm_select_tbl()
for creating a dm
with only a subset of the tables
dm_nycflights13()
for creating an example dm
object
decompose_table()
for table surgery
check_key()
and check_subset()
for checking for key properties
examine_cardinality()
for checking the cardinality of the relation between two tables
dm(trees, mtcars)
new_dm(list(trees = trees, mtcars = mtcars))
as_dm(list(trees = trees, mtcars = mtcars))
is_dm(dm_nycflights13())
dm_nycflights13()$airports
dm_nycflights13()["airports"]
dm_nycflights13()[["airports"]]
dm_nycflights13() %>% names()
library(dm)
library(nycflights13)
# using `data.frame` objects
new_dm(tibble::lst(weather, airports))
# using `dm_keyed_tbl` objects
dm <- dm_nycflights13()
y1 <- dm$planes %>%
mutate() %>%
select(everything())
y2 <- dm$flights %>%
left_join(dm$airlines, by = "carrier")
new_dm(list("tbl1" = y1, "tbl2" = y2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.