0

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

Community
  • 1
  • 1
PeddiePooh
  • 403
  • 8
  • 17
  • 3
    Please provide us with a reproducible example. I would love to take your word for it, but I work best with some code. – Roman Luštrik Mar 06 '16 at 19:09
  • Ok, it's a start. How about some data, too? You can use `dput` to easily output a few lines, or ideally, simulate some data. – Roman Luštrik Mar 07 '16 at 10:12
  • test data is now added :) – PeddiePooh Mar 07 '16 at 15:35
  • "When executing a R script that results in an error, the R visual is not plotted and an error message is displayed on the canvas. For details on the error, select See details from the R visual error on the canvas." For me, this error was regarding installing the stringi package. This resolved the namespace. – shayaa Nov 17 '16 at 04:44

0 Answers0