この投稿R を使用したガント チャートに続いて、リンクと同じデータ構造を使用して data.frame にデータを保存しました。コードは以下のとおりです (最初の 4 行は powerBI によって自動生成され、修正できませんでした。
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"
)
)
R スクリプトを実行すると、次のエラー メッセージが表示されました。
イメージは作成されませんでした。R コードでは、ビジュアルは作成されませんでした。R スクリプトが R の既定のデバイスにプロットされることを確認します。
なぜこれが起こったのかアドバイスしてください。ありがとうペディ