dm_deconstruct {dm} | R Documentation |
Create code to deconstruct a dm object
Description
Emits code that assigns each table in the dm to a variable,
using pull_tbl()
with keyed = TRUE
.
These tables retain information about primary and foreign keys,
even after data transformations,
and can be converted back to a dm object with dm()
.
Usage
dm_deconstruct(dm, dm_name = NULL)
Arguments
dm |
A |
dm_name |
The code to use to access the dm object, by default the expression passed to this function. |
Value
This function is called for its side effect of printing generated code.
Examples
dm <- dm_nycflights13()
dm_deconstruct(dm)
airlines <- pull_tbl(dm, "airlines", keyed = TRUE)
airports <- pull_tbl(dm, "airports", keyed = TRUE)
flights <- pull_tbl(dm, "flights", keyed = TRUE)
planes <- pull_tbl(dm, "planes", keyed = TRUE)
weather <- pull_tbl(dm, "weather", keyed = TRUE)
by_origin <-
flights %>%
group_by(origin) %>%
summarize(mean_arr_delay = mean(arr_delay, na.rm = TRUE)) %>%
ungroup()
by_origin
dm(airlines, airports, flights, planes, weather, by_origin) %>%
dm_draw()
[Package dm version 1.0.10 Index]