rdiagrammer

Diagrammer: how to add labels to mermaid connectors


I am trying R DiagrammeR library, and can noT add a label for the connectors between boxes... My code (which works fine) is:

library(DiagrammeR)
mermaid("
graph TD
        A[node 1]-->B[node 2]
        A-->C[node 3]
        C-->E[another node]
        B-->D[node 4]
        ")

Using the function grViz of the same library, labels could be added like:

 A[label:'This is the NO path"]

but this way gives error in mermaid function... I tried:

 A[node 1]-->B[node 2][label="test"]
 A[node 1]-->B[node 2, label="test"]

and many others with no success.

I want something similar to this diagramm with the 'YES' added in a connection enter image description here

Any ideas? Thanks in advance!


Solution

  • Add |Yes| between A--> and C[node 3].

    library(DiagrammeR)
    mermaid("
    graph TD
            A[node 1]--> B[node 2]
            A-->|Yes| C[node 3]
            C-->E[another node]
            B-->D[node 4]
            ")
    

    enter image description here