I'm having trouble getting some plotting functions to work, while others work fine. Here's an example. The first plot (with plot() function) works fine. The second plot with DiagrammeR mermaid() function doesn't work. The plot pane goes blank, and for some reason the 'Viewer' pane becomes the active pane, rather than the 'Plots' pane, but the Viewer pane remains blank too (i.e. I am not able to see any output). There is no error nor warning shown in the console.
# example I'm trying to work through, from https://stackoverflow.com/questions/3550341/gantt-charts-with-r:
df <- data.frame(task = c("task1", "task2", "task3"),
status = c("done", "active", "crit"),
pos = c("first_1", "first_2", "first_3"),
start = c("2014-01-06", "2014-01-09", "after first_2"),
end = c("2014-01-08", "3d", "5d"))
plot(df$task, df$end) # random plot which DOES show in the plots pane
# Using dplyr and tidyr (or any of your favorite data wrangling resources):
library(tidyr); library(dplyr)
mermaid(
paste0(
# mermaid "header", each component separated with "\n" (line break)
"gantt", "\n",
"dateFormat YYYY-MM-DD", "\n",
"title A Very Nice Gantt Diagram", "\n",
# unite the first two columns (task & status) and separate them with ":"
# then, unite the other columns and separate them with ","
# this will create the required mermaid "body"
paste(df %>%
unite(i, task, status, sep = ":") %>%
unite(j, i, pos, start, end, sep = ",") %>%
.$j,
collapse = "\n"
), "\n"
)
)