我正在通过创建条形图比较来自两个数据集的5年月度值的总和。我想添加较高的误差线。 这是我的条形图代码:
library(tibble)
library(lubridate)
library(dplyr)
library(ggplot2)
tb = tibble(Date = seq(mdy('1/1/1997'),mdy('12/31/1999'),by = '1 week')) %>%
mutate(sum_sed= sample(0:10,n(),replace=TRUE)) %>%
group_by(Month = month(Date,label = TRUE),year = as.integer(year(Date)))
tb2 = tibble(Date = seq(mdy('1/1/1997'),by = '1 week')) %>%
mutate(sum_sed= sample(11:20,replace=TRUE)) %>%
group_by(Month = month(Date,year = as.integer(year(Date)))
tb_all <- bind_rows(tb %>%
mutate(Month = month(Date,Year = as.integer(year(Date))),tb2 %>%
mutate(Month = month(Date,Year = as.integer(year(Date)))) %>%
group_by(Model,Year,Month) %>%
summarize(Sum_Sed_yield = sum(Sed_yield))
## plotting bar chart
tb_all %>%
ggplot(aes(factor(Month),Sum_Sed_yield,fill = Model))+
geom_bar(stat ="identity",position = "dodge")+
facet_wrap(vars(Year),nrow = 1)+
theme(axis.text.x = element_text(angle = 90,hjust = 1,size = 9))
如何在每个误差线上添加上误差线?