Package 'DOT'

Title: Render and Export DOT Graphs in R
Description: Renders DOT diagram markup language in R and also provides the possibility to export the graphs in PostScript and SVG (Scalable Vector Graphics) formats. In addition, it supports literate programming packages such as 'knitr' and 'rmarkdown'.
Authors: E. F. Haghish
Maintainer: E. F. Haghish <[email protected]>
License: MIT + file LICENSE
Version: 0.1
Built: 2024-11-25 03:37:59 UTC
Source: https://github.com/haghish/dot

Help Index


Render and Export DOT Graphs in R

Description

Graph Description Language (DOT) is a simplified and intuitive plain text graphical language. The dot() function renders the DOT markup language in R and also provides the possibility to export the graphs in PostScript and SVG (Scalable Vector Graphics) formats. In addition, it supports literate programming packages such as Knitr and R2HTML. Visit http://haghish.com/dot for downloading examples of creating algorithms and several graphs for Rmarkdown and R HTML to generate dynamic procedural graphs in dynamic documents using the DOT package.

Usage

dot(DOT, file = NULL, return = "auto", display = TRUE)

Arguments

DOT

This argument takes a string containing the DOT script. It is advised to use single quotation mark for the DOT string since the script often includes double quotations which can crash the function.

file

defines the file name for exporting the graph. The acceptable file extensions are "ps" for PostScript and "svg" for SVG format (see examples below).

return

specifies if PS or SVG script should be printed in R console. The acceptable values are "auto", "cat", "verbatim", and NULL. The default value is "auto" which does not return anything unless the dot() function is called within 'knitr' or 'rmarkdown' packages, which require concatenated graphical script. The "cat" returns concatenated PS or SVG script, printed in multiple lines in the R console. The "verbatim" returns a single string which is assignable to an object.

Value

By default, the function only renders and loads the DOT plot in RStudio but does not return any PS or SVG script. If the return argument is specified, it returns PostScript or SVG script. Note that for assigning the script returned from dot() to an object, only "verbatim" value can be used to create a string object.

Author(s)

E. F. Haghish
Medical Informatics and Biostatistics (IMBI)
University of Freiburg, Germany
[email protected]

Department of Mathematics and Computer Science
University of Southern Denmark
[email protected]

Examples

#create a simple DOT graph and load it in RStudio
dot("digraph {A -> B;}")

#to produce a dynamic document including a diagram in 'rmarkdown'
## Not run: 
```{r echo=FALSE, results='asis'}
library(DOT)
dot("digraph {A -> B;}", return = "cat")
```
## End(Not run)


#create a DOT graph and export a SVG file to the working directory
dot("digraph {A -> B; B -> C; B -> D;}", file = "myfile.svg")

#export the example above in PostScript format
dot("digraph {A -> B; B -> C; B -> D;}", file = "myfile.ps")

#create a DOT graph and save the script in a string object in R
myString <- dot("digraph {A -> B;}", return = "verbatim", display = FALSE)