p <- pipe_new("pipe", data = 1:2)
pipe_add(p, "add1", \(x = ~data) x + 1)
pipe_add(p, "add2", \(x = ~add1) x + 2)
pipe_add(p, "mult3", \(x = ~add1) x * 3)
pipe_add(p, "mult4", \(x = ~add2) x * 4)
p
pipe_discard_steps(p, "mult")
p
# Re-add steps
pipe_add(p, "mult3", \(x = ~add1) x * 3)
pipe_add(p, "mult4", \(x = ~add2) x * 4)
p
# Discarding 'add1' does not work ...
try(pipe_discard_steps(p, "add1"))
# ... unless we enforce to remove its downstream dependencies as well
pipe_discard_steps(p, "add1", recursive = TRUE)
p
# Trying to discard non-existent steps is just ignored
pipe_discard_steps(p, "non-existent")
Run the code above in your browser using DataLab