as_graph: Conversion to mlr3pipelines Graph

View source: R/assert_graph.R

as_graphR Documentation

Conversion to mlr3pipelines Graph


The argument is turned into a Graph if possible. If clone is TRUE, a deep copy is made if the incoming object is a Graph to ensure the resulting object is a different reference from the incoming object.

as_graph() is an S3 method and can therefore be implemented by other packages that may add objects that can naturally be converted to Graphs.

By default, as_graph() tries to

  • apply gunion() to x if it is a list, which recursively applies as_graph() to all list elements first

  • create a Graph with only one element if x is a PipeOp or can be converted to one using as_pipeop().


as_graph(x, clone = FALSE)



Object to convert.


Whether to return a (deep copied) clone if x is a Graph.


Graph x or a deep clone of it.

See Also

Other Graph operators: %>>%(), as_pipeop(), assert_graph(), assert_pipeop(), chain_graphs(), greplicate(), gunion(), mlr_graphs_greplicate

mlr3pipelines documentation built on May 31, 2023, 9:26 p.m.