How to do it...

In this recipe, we will draw a diagram depicting a company structure. The company is split into three groups, and within each group we will draw the sales in blue and the market share in green.

  1. Import the library:
library('DiagrammeR')
  1. We define the diagram using Graphviz's dot syntax. Essentially, it needs three parts—the graph part controls the global elements of the diagram, the node part defines the nodes, and the edge part defines the edges:
grViz("
digraph dot {

graph [layout = dot]

node [shape = circle,
style = filled,
color = grey,
label = '']

node [fillcolor = white,fixedsize = true, width = 2]
a[label = 'Company A']

node [fillcolor = white]
b[label = 'IT+RD Consulting'] c[label = 'General Consulting'] d[label = 'Other Activities']

node [fillcolor = white]

edge [color = grey]
a -> {b c d}
b -> {e[label = '254';color=blue] f[label = '83%';color=green]}
c -> {k[label = '132';color=blue] l[label = '61%';color=green]}
d -> {q[label = '192';color=blue] r[label = '47%';color=green]}
}")

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.149.252