-
Notifications
You must be signed in to change notification settings - Fork 0
/
MLMC.Rmd
87 lines (73 loc) · 3.66 KB
/
MLMC.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: "My Life, My Council"
author: "A GovHack 2016 Project"
output:
pdf_document:
latex_engine: pdflatex
geometry: margin=2cm
urlcolour: green
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, dev="pdf")
```
My council is **`r input$council`**, and I'm interested in **`r input$cat`**. Funding towards `r sprintf("%s %s", tolower(input$cat), defs.df[input$cat,"Basic.definition."])`
-----
```{r, echo=FALSE}
data.sub.df <- subset(core.df, (Council == input$council) & (Activity == input$cat));
data.sub.df$pct.exp <- signif(data.sub.df$opex.1000 /
total.exp[cbind(data.sub.df$Council,as.character(data.sub.df$Year))] * 100,2);
dataMax <- max(data.sub.df$pct.exp);
plot(data.sub.df$Year, data.sub.df$pct.exp, ylim=c(0,dataMax),
ylab=sprintf("Percent Expenditure"), main=input$cat,
xlab="Year", type="b", lwd=2, col="darkgreen");
mtext(input$council, 3, 0.5, cex=0.75);
```
-----
**Contact** | **Detail**
----------- | ----
Authority | `r input$council`
Phone | `r contacts.df[input$council,"Phone"]`
Post | `r contacts.df[input$council,"Post"]`
Email | [`r contacts.df[input$council,"Email"]`](mailto:`r contacts.df[input$council,"Email"]`)
Website | [`r contacts.df[input$council,"URL"]`](http://`r contacts.df[input$council,"URL"]`)
Councils are grouped into Unitary, Regional, and Territorial authorities, because each of these groups are responsible for different activities. My council, **`r input$council`**, is a **`r tags$b(type.df[input$council,"Council.Type"])`** Authority.
See [Internal Affairs][1] and [Statistics New Zealand][2] for more information.
[1]: http://www.localcouncils.govt.nz/lgip.nsf/wpg_url/About-Local-Government-Index
[2]: http://datainfoplus.stats.govt.nz/Item/nz.govt.stats/319be03d-287d-4384-993a-d38ef9acb3e6#/nz.govt.stats/6b459c66-0e05-4aa7-997e-d4a5e40941dd
```{r, echo=FALSE, fig.height=9, fig.width=8}
councilType <- type.df[input$council,"Council.Type"];
typeCount <- sum(type.df$Council.Type == councilType);
data.sub.df <- subset(core.df, (Year == lastYear) & (Activity == input$cat) &
Council.Type == councilType);
data.sub.df$pct.exp <-
signif(data.sub.df$opex.1000 / total.exp[cbind(data.sub.df$Council,
as.character(data.sub.df$Year))] * 100,2);
council.value <- subset(data.sub.df, Council == input$council)$pct.exp;
data.sub.df$order <-
if(input$sortBy == "descending") {
order(data.sub.df$pct.exp);
} else if(input$sortBy == "ascending"){
order(-data.sub.df$pct.exp);
} else if(input$sortBy == "alpha"){
order(-xtfrm(data.sub.df$Council));
}
data.sub.df <- data.sub.df[data.sub.df$order,];
data.sub.df$col <- ifelse(c(data.sub.df$Council == input$council),"#23723F","#90DDAB");
councilLabels <- c(data.sub.df$Council,"",input$council);
par(mar = c(1,20,5,2));
dataMax <- max(data.sub.df$pct.exp);
res <- barplot(c(data.sub.df$pct.exp,0,council.value),
names.arg=councilLabels, cex.names=0.65,
horiz=TRUE, las=2,
col=c(data.sub.df$col,NA,"#23723F"),
border=NA, xaxt="n");
abline(h=head(tail(res,2),1),lty="dotted", lwd=3);
text(x=c(data.sub.df$pct.exp,NA,council.value), y=res, pos=4,
labels=c(data.sub.df$pct.exp,NA,council.value), cex=0.65,
col=c(data.sub.df$col,NA,"#23723F"), xpd=TRUE);
mtext("Percent Expenditure",3,3.5, cex=2);
mtext(sprintf("(vs other %s authorities)", tolower(councilType)),3,2.5);
axis(3);
```
-----
Generated `r format(Sys.Date(),"%Y-%b-%d")` using [R Markdown](http://rmarkdown.rstudio.com/).