| dm_zoom_to | R Documentation |
Zooming to a table of a dm allows for the use of many dplyr-verbs directly on this table, while retaining the
context of the dm object.
dm_zoom_to() zooms to the given table.
dm_update_zoomed() overwrites the originally zoomed table with the manipulated table.
The filter conditions for the zoomed table are added to the original filter conditions.
dm_insert_zoomed() adds a new table to the dm.
dm_discard_zoomed() discards the zoomed table and returns the dm as it was before zooming.
Please refer to vignette("tech-db-zoom", package = "dm")
for a more detailed introduction.
dm_zoom_to(dm, table)
dm_insert_zoomed(dm, new_tbl_name = NULL, repair = "unique", quiet = FALSE)
dm_update_zoomed(dm)
dm_discard_zoomed(dm)
dm |
A |
table |
A table in the |
new_tbl_name |
Name of the new table. |
repair |
Either a string or a function. If a string, it must be one of
The The options |
quiet |
By default, the user is informed of any renaming
caused by repairing the names. This only concerns unique and
universal repairing. Set Users can silence the name repair messages by setting the
|
Whenever possible, the key relations of the original table are transferred to the resulting table
when using dm_insert_zoomed() or dm_update_zoomed().
Functions from dplyr that are supported for a dm_zoomed: group_by(), summarise(), mutate(),
transmute(), filter(), select(), rename() and ungroup().
You can use these functions just like you would
with a normal table.
Calling filter() on a zoomed dm is different from calling dm_filter():
only with the latter, the filter expression is added to the list of table filters stored in the dm.
Furthermore, different join()-variants from dplyr are also supported,
e.g. left_join() and semi_join().
(Support for dplyr::nest_join() is planned.)
The join-methods for dm_zoomed infer the columns to join by from the primary and foreign keys,
and have an extra argument select that allows choosing the columns of the RHS table.
And – last but not least – also the tidyr-functions unite() and separate() are supported for dm_zoomed.
For dm_zoom_to(): A dm_zoomed object.
For dm_insert_zoomed(), dm_update_zoomed() and dm_discard_zoomed(): A dm object.
flights_zoomed <- dm_zoom_to(dm_nycflights13(), flights)
flights_zoomed
flights_zoomed_transformed <-
flights_zoomed %>%
mutate(am_pm_dep = ifelse(dep_time < 1200, "am", "pm")) %>%
# `by`-argument of `left_join()` can be explicitly given
# otherwise the key-relation is used
left_join(airports) %>%
select(year:dep_time, am_pm_dep, everything())
flights_zoomed_transformed
# replace table `flights` with the zoomed table
flights_zoomed_transformed %>%
dm_update_zoomed()
# insert the zoomed table as a new table
flights_zoomed_transformed %>%
dm_insert_zoomed("extended_flights") %>%
dm_draw()
# discard the zoomed table
flights_zoomed_transformed %>%
dm_discard_zoomed()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.