Added another example with complete files.
[docutils/kirr.git] / sandbox / docbook / examples / report2 / charts / problem_solve_2010_vs_2011.R
blob00a664451fc956167b576b4cd7170f55506dbdb9
1 rates <- read.csv("../tables/all.csv")\r
2 title = "Problem Solving,  2010, 2011"\r
3 y1 <- rates$hours.problem.solve.2010 \r
4 y2 <- rates$hours.problem.solve.2011\r
5 total.hours.2010 <- rates$hours.outbound.2010 + rates$hours.inbound.2010\r
6 total.hours.2011 <- rates$hours.outbound.2010 + rates$hours.inbound.2011\r
7 \r
8 y1 <- y1/1000\r
9 y2 <- y2/1000\r
10 x <- rates$week\r
11 png(file="problem_solve_2010_2011.png",\r
12 width=5, height=3.5, units="in", res=res)\r
13 xlab.text="Week in Year"\r
14 xlab = xlab.text\r
15 ylab = "hours in thousands"\r
16 if (make.title == T ) top.margin = 3\r
17 if (make.title != T ) title="" \r
18 if (months.grid == T) bottom.margin = 6\r
19 if (months.grid == T) xlab = ''\r
20 margins=c(bottom.margin, 4, top.margin, 0.5) \r
21 par(mar=margins) \r
22 par(mar=margins) \r
23 par('family'='serif')\r
24 y_range = range(y1,y2, na.rm=T)\r
25 plot(x, type='n', xlab=xlab, ylab=ylab, las=1, main=title, \r
26         ylim=c(y_range), axes=F, xlim=c(range(x)))\r
27 axis(1, col=ax_col)\r
28 axis(2, col=ax_col, las=1, at=axTicks(2))\r
29 box(col=box_col)\r
30 rect(38, -10, 39, 300, col=rec_col, border=NA, xpd = F)\r
31 abline( h=axTicks(2), lty=1, lwd=lwd_grid, col=ax_col)\r
33 lines(x,y1,  col=line_colors[1], type="l", lwd=lwd, lty=line_types[1])\r
34 lines(x,y2,  col=line_colors[2], type="l", lwd=lwd, lty=line_types[2])\r
35 if(months.grid == T) mtext(side = 1, xlab.text, line=2)\r
36 source("make_x_axis.R")\r
37 legend("topleft", c("2010","2011"), cex=legend_font_size, \r
38  col=line_colors,  lty=line_types,  bty='y', bg="white", box.lwd=box.lwd)\r
39 dev.off()\r
41 title = "Problem Solving,  2010, 2011"\r
42 y1 <- rates$hours.problem.solve.2010 \r
43 y2 <- rates$hours.problem.solve.2011\r
44 total.hours.2010 <- rates$hours.outbound.2010 + rates$hours.inbound.2010\r
45 total.hours.2011 <- rates$hours.outbound.2011 + rates$hours.inbound.2011\r
46 y1 <- y1/total.hours.2010\r
47 y2 <- y2/total.hours.2011\r
48 y1 <- y1 * 100\r
49 y2 <- y2 * 100\r
50 #png(file="charts/problem_solve2_2010_2011.png",\r
51 #width=5, height=3.5, units="in", res=res)\r
52 #xlab.text="Week in Year"\r
53 #xlab = xlab.text\r
54 #ylab = "percentage to total"\r
55 #if (make.title == T ) top.margin = 3\r
56 #if (make.title != T ) title="" \r
57 #if (months.grid == T) bottom.margin = 6\r
58 #if (months.grid == T) xlab = ''\r
59 #margins=c(bottom.margin, 4, top.margin, 0.5) \r
60 #par(mar=margins) \r
61 #par(mar=margins) \r
62 #par('family'='serif')\r
63 #y_range = range(y1,y2, na.rm=T)\r
64 #plot(x, type='n', xlab=xlab, ylab=ylab, las=1, main=title, \r
65 #        ylim=c(y_range), axes=F, xlim=c(range(x)))\r
66 #axis(1, col=ax_col)\r
67 #axis(2, col=ax_col, las=1, at=axTicks(2))\r
68 #box(col=box_col)\r
69 #rect(38, -10, 39, 300, col=rec_col, border=NA, xpd = F)\r
70 #abline( h=axTicks(2), lty=1, lwd=lwd_grid, col=ax_col)\r
71 #\r
72 #lines(x,y1,  col=line_colors[1], type="l", lwd=lwd, lty=line_types[1])\r
73 #lines(x,y2,  col=line_colors[2], type="l", lwd=lwd, lty=line_types[2])\r
74 #if(months.grid == T) mtext(side = 1, xlab.text, line=2)\r
75 #if(months.grid == T) axis(1, at=at, labels=months, line=4,\r
76 #cex.axis=months.font, lab=NULL)  \r
77 #legend("topleft", c("2010","2011"), cex=legend_font_size, \r
78 # col=line_colors,  lty=line_types,  bty='y', bg="white", box.lwd=box.lwd)\r
79 #dev.off()\r
80 #t1 <- y1[38:52]\r
81 #t2 <- y2[38:52]\r
82 #mean.2010 <- mean(y1)\r
83 #cat("mean for 2010 is", mean.2010, "\n")\r
84 #cat("mean for pre cutover 2011 is", mean(y2[1:37]), "\n")\r
85 #cat("mean for post cutover 2011 is", mean(y2[38:52]), "\n")\r
86 #mean(t2) - mean(t1)\r
87 #t.test(t2,t1)\r
88 #t1 <- y2[1:37]\r
89 #t2 <- y2[38:52]\r
90 ## t.test(t2,t1)\r
91 #s = sum(total.hours.2011)\r
92 #h = .015 * sum(total.hours.2011)\r
93 #t1 <- y1[1:38]\r
94 #t2 <- y2[1:38]\r
95 ## t.test(t1,t2)\r
96 #t1 <- y1[42:52]\r
97 #t2 <- y2[42:52]\r
98 #cat("difference of means between weeks 42-52, 2010, 2011", mean(t2) - mean(t1), "(t test below)\n")\r
99 #t.test(t2,t1)\r
100 #h = .0096 * s\r
101 #cat("The hours extra are", .015 * s, "\n")\r
102 #c = 16.10 * h\r
103 #s * .015 * 16.1\r