在ggalluvial中混合/合并流动
我需要使用ggalluvial创建特定类型的情节。来自包装的小插图:
require(ggalluvial)
data(vaccinations)
vaccinations <- transform(vaccinations,
response = factor(response, rev(levels(response))))
ggplot(vaccinations,
aes(x = survey, stratum = response, alluvium = subject,
y = freq,
fill = response, label = response)) +
scale_x_discrete(expand = c(.1, .1)) +
geom_flow() +
geom_stratum(alpha = .5) +
geom_text(stat = "stratum", size = 3) +
theme(legend.position = "none") +
ggtitle("vaccination survey responses at three points in time")
给出此图:
现在,我需要产生一个图,其中两个不同的节点“ Merge”(或收集)在同一部分中的两个不同的“流”第一个块中的另一个节点(例如,从“始终”和“有时”的流动在“始终”第二个块上的同一部分收敛)。显然,频率将与第一个块和第二个节点不同。
我试图操纵数据库更改频率,但是似乎无法在末端节点的同一部分中进行两个流“收敛”。
有人有猜测吗?
编辑:要回答评论,这是我想到的输出(从另一个答案中获取:创建sankey/冲积图,其中链接在节点上组合):
其中两个“ flow”(从红色和绿色盒子中)“汇聚”在粉红色盒子上(在粉红色盒子上占据同一位置)。
I need to create a particular type of plot using ggalluvial. From the vignette of the package:
require(ggalluvial)
data(vaccinations)
vaccinations <- transform(vaccinations,
response = factor(response, rev(levels(response))))
ggplot(vaccinations,
aes(x = survey, stratum = response, alluvium = subject,
y = freq,
fill = response, label = response)) +
scale_x_discrete(expand = c(.1, .1)) +
geom_flow() +
geom_stratum(alpha = .5) +
geom_text(stat = "stratum", size = 3) +
theme(legend.position = "none") +
ggtitle("vaccination survey responses at three points in time")
Gives this plot:
Now, I need to produce a plot in which two different "flows" from the first block of nodes "merge" (or converge) on the same portion of another node in the first block (for example, the flows from "always" and "sometimes" converge on the same part on the "always" second block). Obviously, the frequencies would be different from the first block and the second block of nodes.
I've tried to manipulate the database changing frequencies, but it seems there is no way to make two flows "converge" on the same section of the end node.
Anyone have a guess?
EDIT: To answer to the comment, this is the output that I have in mind (taken from another answer, here: Create Sankey/ Alluvial diagram in which the links combine at the node):
In which two "flow" (from the red and the green boxes) "converge" on the pink box (occupying the same place on the pink box).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论