### Create an example source
exampleSource <- '
---
codes:
-
id: parentCode
label: Parent code
children:
-
id: childCode1
-
id: childCode2
-
id: childCode3
label: Child Code
parentId: parentCode
children: [grandChild1, grandChild2]
---
';
### Parse it
parsedSource <-
rock::parse_source(
text = exampleSource
);
### Extract the deductive code tree from
### the parsed source
deductiveCodeTree <-
parsedSource$deductiveCodeTrees;
### Convert it to a DiagrammeR graph
miniGraph <-
data.tree::ToDiagrammeRGraph(
deductiveCodeTree
);
### Show the graph
DiagrammeR::render_graph(
miniGraph
);
### Apply a "theme" (three attributes)
miniGraph_themed <-
rock::apply_graph_theme(
miniGraph,
c("rankdir", "TB", "graph"),
c("shape", "square", "node"),
c("style", "solid", "node"),
c("fontname", "Arial", "node"),
c("fontcolor", "#0000BB", "node"),
c("color", "#BB0000", "node")
);
### Show the updated graph
DiagrammeR::render_graph(
miniGraph_themed
);
Run the code above in your browser using DataLab