我想使用 R 中的 DiagrammeR 包绘制水平图。但是我只发现绘制垂直图。知道如何将其翻转 90° 吗?
library(DiagrammeR)
library(dplyr)
create_graph() %>%
add_nodes_from_table(table=n,label_col = task) %>%
add_edges_from_table(table=e,from_col = from,to_col = to,from_to_map = label) %>%
set_node_attrs(
node_attr = "shape",
values = "square"
) %>%
render_graph(layout = "tree")
结果 :
输入:
n <- structure(list(task = c("1", "2", "3", "4", "5", "6", "7", "8",
"A", "B", "C")), .Names = "task", row.names = c(NA, -11L), class = "data.frame")
e <- structure(list(from = c("A", "1", "2", "4", "B", "3", "C", "5"
), to = c("1", "2", "4", "8", "3", "6", "5", "7")), .Names = c("from",
"to"), row.names = c(NA, -8L), class = "data.frame")