我试图创建一个图表的图片,但它只是创建了空白文件。我的数据框如下所示:
df <- data.frame(col1 = c( "猫", "狗", "鸟"),
col2 = c( "Feline", "Canis", "Avis"),
stringsAsFactors=FALSE)
png("C:\\tmp\\anim.png")
uniquenodes <- unique(c(df$col1, df$col2))
library(DiagrammeR)
nodes <- create_node_df(n=length(uniquenodes), nodes = seq(uniquenodes), type="number", label=uniquenodes)
edges <- create_edge_df(from=match(df$col1, uniquenodes), to=match(df$col2, uniquenodes), rel="related")
g <- create_graph(nodes_df=nodes, edges_df=edges)
render_graph(g)
dev.off()