| pip_replace | R Documentation |
Replaces a step's function while keeping it in the same position in the
pipeline. Downstream steps that have run before are automatically marked as
outdated and will re-run on the next pip_run().
pip_replace(x, step, fun, tags = NULL, params = list(), exec = NULL)
x |
A pipeflow pipeline or view object. |
step |
Unique step name. |
fun |
Function to execute for the step. Each function parameter must
have a default value. Default values that are simple constants are resolved
immediately. Default values that are formulas like |
tags |
Optional character vector of tags belonging to the step. If
|
params |
Optional named list of parameter values, which will be merged
with the defaults of
|
exec |
Execution mode for the step, see |
By default, the step keeps its tags and execution mode: tags = NULL and
exec = NULL mean "keep the current value". To change them, pass explicit
values, where tags = character(0) removes all tags and exec = "auto"
resets the execution mode to its default. Parameters, output, state and
lock status are always reset, like for a freshly added step.
The updated pipeline, invisibly.
p <- pip_new() |>
pip_add("load", \(n = 5) seq_len(n)) |>
pip_add("double", \(x = ~load) x * 2)
pip_run(p)
p
# Replace "load" — downstream steps are automatically marked "outdated"
pip_replace(p, "load", \(n = 3) seq_len(n))
p
# Re-run to bring everything up to date
pip_run(p)
p
# If a view is passed, the step must be part of the view
v <- pip_view(p, step = "double")
pip_replace(v, "double", \(x = ~load) x * 3)
p[["state"]] # "double" is "new" again
try(pip_replace(v, "load", \(n = 2) seq_len(n)))
# Tags and execution mode are kept unless set explicitly
pip_tag(p, "io")
pip_replace(p, "load", \(n = 4) seq_len(n))
p[, "tags"]
pip_replace(p, "load", \(n = 4) seq_len(n), tags = character(0))
p[, "tags"]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.