You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 04-content.Rmd
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -575,7 +575,7 @@ While there are several different packages available for R, we will only briefly
575
575
576
576
The RStudio IDE provides native support for Graphviz (`.gv`) and mermaid (`.mmd`) files. Editing these types of files in RStudio has the advantage of syntax highlighting. RStudio also allows you to preview the diagrams by clicking the "Preview" button on the toolbar. Figure \@ref(fig:diagram-profit) is a simple flowchart example that has four rectangles representing four steps, generated by the code below:
There are extensive controls that can be used to define the shape of nodes, colors, line types, and add additional parameters.
595
599
596
600
### Adding parameters to plots
597
601
598
602
Graphviz substitution allows for mixing R expressions into a Graphviz graph specification, without sacrificing readability. If you specify a substitution with `@@`, you must ensure there is a valid R expression for that substitution. The expressions are placed as footnotes and their evaluations must result in an R vector object. The `@@` notation is immediately followed by a number, and that number should correspond to the number of the R expression footnote. Figure \@ref(fig:diagram-params) shows an example of embedding and evaluating R code in the diagram.
599
603
600
-
```{r diagram-params, fig.cap="A diagram using parameters input from R.", fig.dim=c(6, 1), out.width="100%", crop=TRUE}
604
+
```r
601
605
DiagrammeR::grViz("
602
606
digraph graph2 {
603
607
@@ -621,6 +625,10 @@ DiagrammeR::grViz("
621
625
height=100)
622
626
```
623
627
628
+
```{r diagram-params, echo=FALSE, fig.cap="A diagram using parameters input from R.", out.width="100%"}
You may also check out these packages for creating diagrams: **nomnoml**[@R-nomnoml], **diagram**[@R-diagram], **dagitty**[@R-dagitty], **ggdag**[@R-ggdag], and **plantuml** (https://github.com/rkrug/plantuml).
0 commit comments