How to insert greek characters in DiagrammeR ?

167 Views Asked by At

I would like to know how can I do for insert greek characters in DiagrammeR. I'm working with DiagrammeR version 1.0.0, R version 3.4.4 (2018-03-15), RStudio Version 0.99.896.

1

There are 1 best solutions below

0
On

The greekLetters package is your friend. Please follow the steps and the example code below:

1. Install and load the greekLetters package

library(DiagrammeR)

# install.packages("greekLetters") if you haven't install it
library(greekLetters)

2. Run a simple graph with English letters

DiagrammeR(
  "graph LR
  A --> B
  ")

You will see:

enter image description here

3. View Greek letters by using the greeks() function

For example, by running:

greeks("alpha") 

You will get:

 "α"

4. Assembling Greek letters together with DiagrammeR

Run:

A <- greeks("alpha")                          # Assign α as A
B <- greeks("beta")                           # Assign β as B

diagram <- paste0("graph LR;", A, "-->", B)   # Assembling A and B with Mermaid string 

DiagrammeR(diagram = diagram)                 # create graph by calling the string

You will then get the Greek equivalent of the English graph:

enter image description here