| pip_new | R Documentation |
Creates a new, empty pipeline. Add steps with pip_add() and execute
them with pip_run().
pip_new(name = "pipe")
name |
The name of the pipeline used for display and logging. |
A pipeflow pipeline object.
A pipeline can be saved with saveRDS() and read back with readRDS()
(or serialized in other ways, e.g. to send it to another R process), with
its steps, parameters, outputs and states. The dependency graph of the
steps is kept outside of R and is not saved, but it is rebuilt from the
steps the first time it is needed. Views that are saved in the same object
as their pipeline, as in saveRDS(list(p, v), file), are read as views of
the read pipeline. A view that is saved on its own is read with its own
copy of the pipeline.
p <- pip_new("demo") |>
pip_add("numbers", \(n = 5) seq_len(n)) |>
pip_add("squared", \(x = ~numbers) x^2) |>
pip_add("total", \(x = ~squared) sum(x))
p
str(p)
p[["name"]] # "demo"
p[["view"]] # initially NULL
# Inner pipeline environment (for advanced usage)
ls(p[["pipenv"]]) # shows "data"
ls(p[["pipenv"]], all = TRUE) # also shows hidden variables
# Save the pipeline and read it back
file <- tempfile(fileext = ".rds")
saveRDS(p, file)
p2 <- readRDS(file)
pip_run(p2)
p2
unlink(file)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.