Creating flowchart from if-else code

Hi everyone, I wonder if there is a way to create a flowchart out of R code.

For example, I want the following function in R:

give_me_food <- function(animal) {
  if (animal == "monkey") {
    food <- "banana"
  } else {
    food <- "hamburger"


Will be documented with the following mermaid code:

    A["Is Monkey?"] -->|"Yes"| B["Banana"]
    A["Is Monkey?"] -->|"No"| C["Hamburger"]

I searched for you and DiagrammeR supports mermaid code for diagrams.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.