1 rates <- read.csv("../tables/all.csv")
3 title='Return Rates, 2010, 2011'
4 y1 = rates$rate.returns.2010
5 y2 = rates$rate.returns.2011
6 png(file="return_rate_2010_2011.png", width=5, height=3.5, units="in", res=res)
9 ylab = "units/man hour"
10 if (make.title == T) top.margin = 3
11 if (make.title != T) title=""
12 if (months.grid == T) bottom.margin = 6
13 if (months.grid == T) xlab = ''
14 margins=c(bottom.margin, 4, top.margin, 0.5)
17 y_range = range(y1, y2, na.rm=T)
18 plot(x, type='n', xlab=xlab, ylab=ylab, las=1, main=title, ylim=c(range(y1,y2,na.rm=T)), axes=F)
20 axis(2, col=ax_col, las=1, at=axTicks(2))
22 abline( h=axTicks(2), lty=1, lwd=lwd_grid, col=ax_col)
23 lines(x,y1, col=line_colors[1], type="l", lwd=lwd, lty=line_types[1])
24 lines(x,y2, col=line_colors[2], lwd=lwd, lty=line_types[2])
25 error_bars = predict(lm(y1[20:40]~x[20:40]), interval='confidence')
26 #segments(20,error_bars[1], 40, error_bars[20], col=line_colors[1])
27 error_bars = predict(lm(y2[20:40]~x[20:40]), interval='confidence')
28 #segments(20,error_bars[1], 40, error_bars[20], col=line_colors[2])
29 legend("bottomleft", c("2010","2011"), cex=legend_font_size,
30 col=line_colors, lty=line_types, bty='y', box.lwd=box.lwd)
31 source("make_x_axis.R")
33 t.results <- t.test(y1,y2)
34 m.diff <- mean(y1) - mean(y2)
35 conf.int <- abs(m.diff - t.results$conf.int[1])
39 percent.diff <- abs((x1 - x2)/((x1 + x2)/2) * 100)
40 # cat("diff in mean is", m.diff, "with +-", conf.int, "and percent change is", percent.diff, "\n")
42 percent.change <- (x2 - x1)/x1 * 100
43 percent.change.low <- ((x2 + conf.int) - x1)/x1 * 100
44 percent.change.high <- ((x2 - conf.int) - x1)/x1 * 100
46 percent.conf.int <- abs((percent.change.high - percent.change.low)/2)
48 # cat("percent change is", percent.change, "+-", percent.conf.int, "\n")