使用已经成型的数据框的森林图

Forest graph using a dataframe already shaped

问题

我有几个数据集,其中的数据已按以下结构处理和导出:

set.seed(123)
library(dplyr)
tb <- tibble(group = rep(c("A", "B"), each = 5),
             wkday = rep(c("Mon", "Tue", "Wed", "Thu", "Fri"), times = 2),
             sta = sample(-3:2, size = 10, replace = T),
             mid = sta + 2,
             fin = sta + 5)

问题

我想生成如下图所示的图。我如何使用 ggplot、ggpubr 或任何其他 R 包生成这样的图?

这应该让你开始:

library(ggplot2)
ggplot(tb, aes(x=wkday, y= mid, ymin= sta, ymax=fin, lower = sta, upper = fin, middle = mid, fill= group)) +
  geom_boxplot(stat = "identity") +
  geom_hline(yintercept=0, linetype="dotted")+
  coord_flip()