gpt4 book ai didi

r - 在R中创建组织结构图

转载 作者:行者123 更新时间:2023-12-04 09:37:30 25 4
gpt4 key购买 nike

我需要在R中绘制公司的组织结构图。我有一个示例,但我希望箭头也指向同一点。

我的期望(来自PowerPoint):



我得到的(在R中):



码:

grViz("
digraph {

graph[splines=ortho, nodesep=1]

node[shape=box]
President;Fun1;Fun2;Fun3;

President->{Fun1,Fun2,Fun3}
}
")

最佳答案

您需要利用空白/空节点,类似这样(如果您不希望箭头将[dir = none]添加到最后一行,例如(blank_3 -> Fun1 [dir = none]):

library(DiagrammeR)

grViz("
digraph {

node[shape=box, width = 4, height = 1]

blank_1 [label = '',color = white];
President;
blank_2 [label = '',color = white];

blank_3[label = '', width = 0.01, height = 0.01];
blank_4[label = '', width = 0.01, height = 0.01];
blank_5[label = '', width = 0.01, height = 0.01];

Fun1;
Fun2;
Fun3;

{rank = same; blank_1 President blank_2}
{rank = same; blank_3 blank_4 blank_5}
{rank = same; Fun1 Fun2 Fun3}

blank_1 -> President [dir = none, color = White]
President -> blank_2 [dir = none, color = White]
President -> blank_4 [dir = none]
blank_1 -> blank_3 [dir = none, color = White]
blank_2 -> blank_5 [dir = none, color = White]
blank_3 -> blank_4 [dir = none]
blank_4 -> blank_5 [dir = none]
blank_3 -> Fun1
blank_4 -> Fun2
blank_5 -> Fun3

}
")


enter image description here

关于r - 在R中创建组织结构图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53753625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com