DRDataRaft/ docs
GitHub ↗

product-dplyr()

Ordinary dplyr verbs append deferred transformations to a product. They use the same data masking, tidy selection and grouping rules as dplyr on the acquired table. Nothing is read until dr_run() or dr_publish().

Usage

\method{mutate}{dr_product}(.data, ...)

\method{filter}{dr_product}(.data, ..., .by = NULL, .preserve = FALSE)

\method{select}{dr_product}(.data, ...)

\method{rename}{dr_product}(.data, ...)

\method{relocate}{dr_product}(.data, ..., .before = NULL, .after = NULL)

\method{arrange}{dr_product}(.data, ..., .by_group = FALSE)

\method{group_by}{dr_product}(.data, ..., .add = FALSE, .drop = dplyr::group_by_drop_default(.data))

\method{ungroup}{dr_product}(x, ...)

\method{summarise}{dr_product}(.data, ..., .by = NULL, .groups = NULL)

\method{distinct}{dr_product}(.data, ..., .keep_all = FALSE)

\method{count}{dr_product}(x, ..., wt = NULL, sort = FALSE, name = NULL)

Arguments

.data, x
Product definition.


...
Arguments captured and passed to the corresponding dplyr verb.


.by, .preserve, .by_group, .add, .drop, .groups, .keep_all, .before, .after, wt, sort, name
Arguments with their usual dplyr meanings, evaluated during execution.

Value

An updated product definition.

Details

Expressions retain their R environments. Inspection records expressions, plus non-disclosing hashes of referenced lexical bindings. Known input columns take precedence over ambient names; use .env$name for explicit lexical bindings and .data$name for columns. Changing an external binding can change a later run: use an explicit code_version when enabling lake caching, and an explicit targets cue for dynamic environment or external state. To freeze a small value in an expression, inject it with !!.

Use dr_step_transform() for other functions. Multiple primary sources must first be combined by a transformation; dr_step_lookup() adds a checked auxiliary source without changing the primary table. left_join() on a product gives guidance rather than guessing relationship rules. Use dr_add_lookup(reference, by = ..., name = "reference") for checked enrichment, or join ordinary tables inside dr_add_transform() for other joins.

Examples

orders <- dr_product("orders", data.frame(group = c("a", "a"), amount = c(10, 20))) |>
  dplyr::mutate(tax = amount * 0.2) |>
  dplyr::summarise(total = sum(amount), .by = group)
orders |> dr_run() |> dr_collect()
Documentation source snapshot · View source at d9cb454 ↗
Code examples are documented source examples; they are not executed in this website build.

Search documentation

Search functions, packages and guides.