【发布时间】:2021-09-06 11:17:25
【问题描述】:
这是我的数据框
dput(LSC)
structure(list(WBC = c(23.8, 162.4, 77.1, 155.1, 135.4, 23.3,
NA, 88.2), Age = c(72.2638888888889, 65.0833333333333, 65.6972222222222,
59.7666666666667, 22.7361111111111, 71.1972222222222, 67.7805555555556,
46.8888888888889), Pre_leukemic_burden = c(96.2, 98.14, 100,
99.84, 81.5, 97.64, 93.32, 100), Donor = structure(1:8, .Label = c("L1",
"L2", "L3", "L4", "L5", "L6", "L7", "L8"), class = "factor"),
Survival = structure(c(2L, 2L, 2L, 1L, 2L, 2L, 2L, 1L), .Label = c("Alive",
"Deceased"), class = "factor")), class = "data.frame", row.names = c(NA,
-8L))
所以在这里我有一个变量是生存,我也有更多,但其他变量是连续变量。 我对每个患者的目标是我想显示每个 WBC 的水平、白血病负担和年龄。
df.long <- gather(LSC, variable,value, -Donor,-Survival)
df.long
ggplot(data = df.long, aes(x = Donor, y = value, fill = variable)) +
geom_col(position = position_dodge()
现在我有更多的分类变量,其中一个是生存。那么有没有办法可以将 survival 标签合并到情节中。
任何建议或帮助将不胜感激。
【问题讨论】:
-
facet_wrap(~survival, scale = "free_x")怎么样 -
是的,谢谢。这是我每天的奋斗生物学家尝试数据分析 + 数据可视化的简单概念,但没有引起我的注意