mean<-aggregate(cum.N2O ~ EC+Moist+as.factor(Urea), salinity, FUN="mean")
sd<-aggregate(cum.N2O ~ EC+Moist+as.factor(Urea), salinity, FUN="sd")
然后我将手段绑定在不同的数组中(从此处运行代码)
Moist_40<- array(c(2.036,2.648,4.257,4.256,4.995,4.647), dim=c(2,3), dimnames=list(c("Without", "With"), c("EC_0.44", "EC_4.55", "EC_7.20")))
Moist_60 <- array(c(2.515,4.310,3.826,4.797,4.767,4.876), dim=c(2,3), dimnames=list(c("Withoout", "With"), c("EC_0.44", "EC_4.55", "EC_7.20")))
Moist_80 <- array(c(2.543,5.045,4.748,6.760,4.889,5.766), dim=c(2,3), dimnames=list(c("Without", "With"), c("EC_0.44", "EC_4.55", "EC_7.20")))
然后将数组绑定在表中
TAB <- rbind(Moist_40, Moist_60, Moist_80)
并制作了一个情节
barplot <- barplot(TAB, beside = TRUE, axisnames = FALSE,ylim=c(0,8),col=c("white","gray","lightblue","blue","coral1","coral4"),main="EC, Moisture and Urea effect on N2O emission")
mtext(1, at = barplot, text = c("W/O", "W/U"),line = 0, cex = 0.5)
at <- t(sapply(seq(1, nrow(TAB), by = 2),function(x) colMeans(barplot[c(x, x+1), ])))
mtext(1, at = at, text = rep(c("40%", "60%", "80%"), 3),line = 1, cex = 0.75)
mtext(1, at = colMeans(barplot), text = c("EC_0.44", "Ec_4.55", "Ec_7.20"), line = 2)
legend("topleft", title="Treatments", c("40%.W/O", "40%.W/U","60%.W/O", "60%.W/U","80%.W/O", "80%.W/U"), fill=c("white","gray","lightblue","blue","coral1","coral4"), box.lty=0)
box()
现在,如何在此图中添加误差线?