从 DiagrammeR 包创建图形时出错

Error in creating graph from DiagrammeR package

我正在尝试使用来自以下代码的 DiagrammeR 包在 R 中创建一个 node-link 图:

library(DiagrammeR)

nodes <- create_nodes(nodes = 1:7, type = "number")

edges <- create_edges(from = c(1, 1, 2, 2, 3, 3),
                        to = c(2, 3, 4, 5, 6, 7),
                       rel = "leading to")

graph <- create_graph(nodes_df = nodes, 
                      edges_df = edges, 
                      graph_attrs = "layout = dot", 
                      node_attrs = "fontname = Helvetica", 
                      edge_attrs = "color = gray20") 

# View the graph
render_graph(graph)

但我收到以下错误:

Error in create_nodes(nodes = 1:7, type = "number") : 
  could not find function "create_nodes"

是否有其他方法可以在 R 中创建这样的图表:

函数 create_nodescreate_edges 已在一段时间前弃用。这是一些使用替换的代码。

library(DiagrammeR)

nodes <- create_node_df(n=7, type = "number")

edges <- create_edge_df(from = c(1, 1, 2, 2, 3, 3),
                                        to = c(2, 3, 4, 5, 6, 7),
                                        rel = "leading to")

graph <- create_graph(nodes_df = nodes, edges_df = edges)

render_graph(graph)