A recipe records ordered preparation separately from product identity, contracts, and destinations. It does not replace ordinary R transformation code. It makes a preparation sequence inspectable and reusable when that is valuable.
# A tibble: 4 × 4
policy_id broker_id premium status
<int> <int> <dbl> <chr>
1 1 10 1200. active
2 2 20 950. paid_up
3 3 10 601. lapsed
4 4 30 1500 active
The current recipe API includes familiar mutate, filter, select, rename, arrange, summarise, and distinct steps. dr_step_transform() provides an escape hatch for custom functions.
7.2 Lookups make dependencies explicit
The book’s broker reference data is a meaningful dependency of the portfolio product.
The output contract belongs to the data after preparation. If the lookup adds region, the published interface should say whether region is part of the product.
7.3 Recipes and static column lineage
For a bounded set of mutate, select, and rename operations, DataRaft can inspect direct field dependencies without running the recipe.
Unsupported transformations return complete = FALSE rather than a guessed map.
7.4 Keep ordinary code ordinary
Use a recipe when the ordered preparation itself should be inspectable, composed, tested, or connected to lineage. Use an ordinary R function when a local transformation is clearer that way.
If a recipe grows into many transformations with several independently useful outputs, that is often a sign that the workflow contains more than one product.
NoteReproducibility boundary
Recipe expressions retain their R environments. Prefer explicit product sources for business data and stable constants for configuration. A recipe is inspectable preparation, not an isolation sandbox.
7.5 Exercises
Add a rename step and inspect the resulting column lineage.
Replace one declarative step with a custom function. What can static inspection no longer prove?
Decide whether the payment aggregation in the running example belongs inside a policy recipe or deserves a separate product at a new grain.