我想制作一個簡單的流程圖。這是我的代碼:
## Data
x = tibble(qms = c("FLOW", "FLOW"),
move1 = c("Birth", "Birth"),
move2 = c("Direct", NA),
freq = c(100, 50))
## Graph
x %>%
mutate(id = qms) %>%
to_lodes_form(axis = 2:3, id = id) %>%
na.omit() %>%
ggplot(aes(x = x, stratum = stratum, alluvium = id,
y = freq, label = stratum))
scale_x_discrete(expand = c(.1, .1))
geom_flow(aes(fill = qms),stat = "alluvium")
geom_stratum(aes(fill = stratum), show.legend=FALSE)
geom_text(stat = "stratum", size = 3)
這是結果:

我想要的結果是:

如何用缺失值表示遞減模式?
uj5u.com熱心網友回復:
通過稍微重塑您的資料,您可以獲得您想要的。我認為關鍵是將 映射alluvium到固定的東西1,這樣它將成為一個單一的流,并映射stratum到與x.
library(tidyverse)
library(ggalluvial)
x <- tibble(x = c("Birth", "Direct"),
y = c(100, 50))
x %>%
ggplot(aes(x, y, alluvium = 1, stratum = x))
geom_alluvium()
geom_stratum()

創建于 2022-11-15,使用reprex v2.0.2
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/534809.html
標籤:r图表2
上一篇:創建具有特定條件的累積比率列
下一篇:在R中同時將列轉換為長格式
