Following this post Gantt charts with R I stored my data in the data.frame using the same data structure as the link. Code is below (note the first 4 rows are auto generated by powerBI and I couldnt amend it.
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"))
#Create dataframe
dataset <- data.frame(end, start, status, task, pos)
#Remove duplicated rows
# dataset <-unique(dataset)
df <- dataset
library(tidyr)
library(DiagrammeR)
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"
)
)
When running R script, I got the following error message.
No image was created. The R code did not result in creation of any visuals. Make sure your R script results in a plot to the R default device.
Please advice why this happened? THank you Peddie