pipe_replace_step {pipeflow} | R Documentation |
Replace pipeline step
Description
Replaces an existing pipeline step.
Usage
pipe_replace_step(
pip,
step,
fun,
params = list(),
description = "",
group = step,
keepOut = FALSE
)
Arguments
pip |
Pipeline object
|
step |
string the name of the step. Each step name must
be unique.
|
fun |
function or name of the function to be applied at
the step. Both existing and anonymous/lambda functions can be used.
All function parameters must have default values. If a parameter
is missing a default value in the function signature, alternatively,
it can be set via the params argument (see Examples section with
mean() function).
|
params |
list list of parameters to set or overwrite
parameters of the passed function.
|
description |
string optional description of the step
|
group |
string output collected after pipeline execution
(see function pipe_collect_out() ) is grouped by the defined group
names. By default, this is the name of the step, which comes in
handy when the pipeline is copy-appended multiple times to keep
the results of the same function/step grouped at one place.
|
keepOut |
logical if FALSE (default) the output of the
step is not collected when calling pipe_collect_out() after the
pipeline run. This option is used to only keep the results that matter
and skip intermediate results that are not needed. See also
function pipe_collect_out() for more details.
|
Value
returns the Pipeline
object invisibly
See Also
pipe_add()
Examples
p <- pipe_new("pipe", data = 1)
pipe_add(p, "add1", \(x = ~data, y = 1) x + y)
pipe_add(p, "add2", \(x = ~data, y = 2) x + y)
pipe_add(p, "mult", \(x = 1, y = 2) x * y, keepOut = TRUE)
pipe_run(p) |> pipe_collect_out()
pipe_replace_step(p, "mult", \(x = ~add1, y = ~add2) x * y, keepOut = TRUE)
pipe_run(p) |> pipe_collect_out()
try(pipe_replace_step(p, "foo", \(x = 1) x)) # step 'foo' does not exist
[Package
pipeflow version 0.2.2
Index]