1
我一直在嘗試在我的一塊地塊上顯示誤差線,並且差不多都得到了它。除了兩個錯誤條不出現的情況之外,我可以正確顯示錯誤條。這裏是我的代碼:如何修復geom_errorbar輸出錯誤?
adat <- data.frame(1:8)
names(adat)[1] <- "Technology"
adat$Technology <- c("1","1","1","1","2","2","2","2")
adat$Behaviors <- c("Low Moisture","High Moisture","Low Density","High Density","Low Moisture","High Moisture","Low Density","High Density")
adat$Average.duration <- c(374,347,270,313,273,280,242,285)
adat$sd <- c(207,107,120,920,52,61,50,84)
limits <- aes(ymin = adat$Average.duration - adat$sd, ymax = adat$Average.duration + adat$sd)
ggplot(adat, aes(x = Behaviors, y = Average.duration, fill = Technology)) +
geom_bar(stat = "identity", position = "dodge") +
ylim(0,500) +
geom_errorbar(limits, position = position_dodge(.9), width = .75)
我不知道爲什麼兩個誤差線顯示不出來。有什麼建議麼?