Replaces an existing pipeline step.
Usage
pipe_replace_step(
pip,
step,
fun,
params = list(),
description = "",
group = step,
keepOut = FALSE
)Arguments
- pip
Pipelineobject- step
stringthe name of the step. Each step name must be unique.- fun
functionor 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 theparamsargument (see Examples section withmean()function).- params
listlist of parameters to set or overwrite parameters of the passed function.- description
stringoptional description of the step- group
stringoutput collected after pipeline execution (see functionpipe_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
logicalifFALSE(default) the output of the step is not collected when callingpipe_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 functionpipe_collect_out()for more details.
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()
#> INFO [2025-07-27 10:40:29.168] Start run of 'pipe' pipeline:
#> INFO [2025-07-27 10:40:29.169] Step 1/4 data
#> INFO [2025-07-27 10:40:29.171] Step 2/4 add1
#> INFO [2025-07-27 10:40:29.173] Step 3/4 add2
#> INFO [2025-07-27 10:40:29.175] Step 4/4 mult
#> INFO [2025-07-27 10:40:29.177] Finished execution of steps.
#> INFO [2025-07-27 10:40:29.178] Done.
#> $mult
#> [1] 2
#>
pipe_replace_step(p, "mult", \(x = ~add1, y = ~add2) x * y, keepOut = TRUE)
pipe_run(p) |> pipe_collect_out()
#> INFO [2025-07-27 10:40:29.182] Start run of 'pipe' pipeline:
#> INFO [2025-07-27 10:40:29.183] Step 1/4 data - skip 'done' step
#> INFO [2025-07-27 10:40:29.184] Step 2/4 add1 - skip 'done' step
#> INFO [2025-07-27 10:40:29.185] Step 3/4 add2 - skip 'done' step
#> INFO [2025-07-27 10:40:29.186] Step 4/4 mult
#> INFO [2025-07-27 10:40:29.187] Finished execution of steps.
#> INFO [2025-07-27 10:40:29.187] Done.
#> $mult
#> [1] 6
#>
try(pipe_replace_step(p, "foo", \(x = 1) x)) # step 'foo' does not exist
#> Error : step 'foo' does not exist
