[R Course] How to: Create Diagrams

Easily create diagrams with R by using DiagrammeR.

Thierry Warin https://warin.ca/aboutme.html (HEC Montréal and CIRANO (Canada))https://www.hec.ca/en/profs/thierry.warin.html
01-30-2020


Nüance-R provides this course to teach you how to create a diagram.

Open the following packages


library(igraph)
library(DiagrammeR)

Create your diagram


DiagrammeR::grViz("digraph graph2 

# Choose the layout of your graph

{graph [layout = dot] 

# Customize your nodes

node [shape = rectangle, width = 1, style = filled, color = grey]

node [fillcolor = plum]
a

node [fillcolor = azure]
b c d

node [fillcolor = GreenYellow]
h i

node [fillcolor = gold]
s t u v

node [fillcolor = mistyrose]
k l

node [fillcolor = navajowhite]
g

node [fillcolor = lavender]
j

node [fillcolor = paleturquoise]
e f

node [fillcolor = honeydew]
n o p

node [fillcolor = seashell]
q r

node [fillcolor = yellow]
m

# Assign a label to each node

a [label = 'Data Science']
b [label = 'Big Data']
c [label = 'Algorithms']
d [label = 'Stats']
e [label = 'Econometrics']
f [label = 'Bayesian Statistics']
g [label = 'AI']
h [label = 'Structured']
i [label = 'Unstructured']
j [label = 'Domains']
k [label = 'Augmented Intelligence']
l [label = 'Automated Intelligence']
m [label = 'engineering']
n [label = 'social sciences']
o [label = 'management']
p [label = 'decision theory']
q [label = 'data frames']
r [label = 'tables']
s [label = 'text']
t [label = 'images']
u [label = 'sounds']
v [label = 'videos']

# Assign a path to each node

a -> b
a -> c
a -> d
b -> h
b -> i
c -> g
d -> e
d -> f
g -> j
j -> k
j -> l
k -> n
k -> o
k -> p
l -> m
i -> s
i -> t
i -> u
i -> v
h -> q
h -> r

}

")

For more information about the diagrammeR package, click here

Citation

For attribution, please cite this work as

Warin (2020, Jan. 30). Thierry Warin: [R Course] How to: Create Diagrams. Retrieved from https://warin.ca/posts/howto-creatediagrams/

BibTeX citation

@misc{warin2020[r,
  author = {Warin, Thierry},
  title = {Thierry Warin: [R Course] How to: Create Diagrams},
  url = {https://warin.ca/posts/howto-creatediagrams/},
  year = {2020}
}