16 Nodes, Edges and Graphs
POs are combined into Graph
s.
POs are identified by their $id
. Note that the operations all modify the object in-place and return the object itself. Therefore, multiple modifications can be chained.
For this example we use the pca
PO defined above and a new PO named “mutate”. The latter creates a new feature from existing variables. Additionally, we use the filter PO again.
The recommended way to construct a graph is to use the %>>%
operator to chain POs or Graph
s.
graph = mutate %>>% filter
To illustrate how this sugar operator works under the surface we will include an example of the manual way (= hard way) to construct a Graph
. This is done by creating an empty graph first. Then one fills the empty graph with POs, and connects edges between the POs. Conceptually, this may look like this:
graph = Graph$new()$
add_pipeop(mutate)$
add_pipeop(filter)$
add_edge("mutate", "variance") # add connection mutate -> filter
The constructed Graph
can be inspected using its $plot()
function:
graph$plot()
Chaining multiple POs of the same kind
If multiple POs of the same kind should be chained, it is necessary to change the id
to avoid name clashes. This can be done by either accessing the $id
slot or during construction:
graph$add_pipeop(po("pca"))
graph$add_pipeop(po("pca", id = "pca2"))
graph$plot()