Learn R Programming

qreport (version 1.0-2)

makegvflow: Create a Quarto Graphviz Flow Diagram from Plain Text With Variable Insertions

Description

Takes a character string or vector and creates a graphviz flowchart from the hierarchy indicated by the number of indended spaces in each line. The text for the root levels is not indented, and major, minor, and tiny levels are indented 2, 4, or 6 spaces, respectively. Default color, font size, and fill color are chosen so that the chart is suitable for presentations. Simple $LaTeX$ math markup is converted to simple HTML markup using tth::tth(). Text lines are automatically wrapped to keep text boxes from being too wide. Text lines beginning with "+" are combined with the previous major, minor, or tiny text line but separated by a double line break (single break if lbdouble=FALSE).

Usage

makegvflow(
  .object.,
  ...,
  direction = c("TD", "LR"),
  style = "filled",
  shape = "box",
  font = "Times-Roman",
  fontsize = 18,
  fontcolor = "blue",
  fillcolor = "azure",
  penwidth = 0.1,
  arrowcolor = "blue3",
  arrowsize = 0.7,
  width = 30,
  lbdouble = TRUE,
  extracon = NULL,
  file,
  onlyprint = FALSE
)

Value

nothing; used to knitr::knit_expand() graphviz markup

Arguments

.object.

character string or vector of plain text plus possible $LaTeX$ math delimited by single dollar signs. An empty initial line is ignore, so the user need not worry about having an initial quote mark on a line by itself.

...

name=value pairs that makes values replace {{name}} elements in the markup

direction

direction of the flow chart, default is top-down

style

node style

shape

node shape

font

font for text in nodes

fontsize

text font size

fontcolor

text color

fillcolor

node fill color

penwidth

thickness of lines for node borders

arrowcolor

arrow color

arrowsize

arrow size

width

text width for word-wrapping

lbdouble

set to FALSE to use a single line break for "+" lines

extracon

one or more text strings specifying extra connections between nodes using node names nijk for major level i, minor level j, tiny level k (as many of these that are applicable). For example specify extracon=c('n1 -> n2', 'n21 -> n31').

file

name of file to hold graphviz markup after variable insertions. Run this in Quarto using a chunk to looks like what is below, which was for file='graphviz.dot'.

onlyprint

set to TRUE to only print the generated graphiz markup and not save it to file

```{dot}
//| label: fig-flow1
//| fig-height: 4
//| fig-cap: "Chart caption"
//| file: graphviz.dot
```

Author

Frank Harrell

Details

The function uses knitr::knit_expand() to apply variable insertions before the diagram is rendered by Quarto. See this for an example. ##' @title makegvflow

See Also

makegraphviz()

Examples

Run this code
x <- '
Root text
  Major 1
    Minor 11 {{jj}}
    Minor 12
  Major 2
    Minor 21
    Minor 22
    Minor 23 that is very very long and just keeps going
      tiny 231 and $\\alph + \\sum_{i=1}^{n}X_{i}$
      tiny 232
      + a second line for tiny 232 that is pretty long
      + a third line for tiny 232
  Major 3
    Minor 31
      tiny 311'
makegvflow(x, extracon='n12 -> n21', jj='tiger', onlyprint=TRUE)

Run the code above in your browser using DataLab