-
Notifications
You must be signed in to change notification settings - Fork 0
/
glasgow_comparison.Rmd
49 lines (43 loc) · 1.88 KB
/
glasgow_comparison.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
---
title: "**Glasgow City Region local authorities comparison**"
date: "Downloaded on `r Sys.Date()`"
output: pdf_document
params:
Indicator: NA
Bar_Data: NA
Comparator: NA
Time_Data: NA
---
```{r echo=FALSE}
#libraries
library(ggplot2)
measure <- unique(params$Bar_Data$Measure)
comp_value <- unique(params$Bar_Data$Comp_Value)
lower_year <- min(params$Time_Data$Year)
higher_year <- max(params$Time_Data$Year)
number_of_years <- length(unique(params$Time_Data$Year))
```
##**`r params$Indicator`** based on `r unique(latest_data$Year[latest_data$Indicator == params$Indicator])` data compares as follows when looking at the following local authorities within the Glasgow City Region:
```{r echo=FALSE}
kable(params$Bar_Data[,c("Region","Value","Measure")])
```
## Local authorities compared to **`r params$Comparator`** with a value of `r comp_value`.
```{r echo=FALSE, results='hide'}
ggplot(data=params$Bar_Data) +
geom_bar(aes(x=Region,y=Value), stat="identity", fill="#E9BD43") +
geom_line(aes(x=Region,y=Comp_Value), stat="identity", group = 1, color = "#7d3778") +
scale_x_discrete(labels = function(x) str_wrap(x, width = 10))
labs(x="",y=measure) + theme_minimal()
```
\newpage
## Historic data for `r params$Indicator` and local authorities selected
```{r echo=FALSE}
timeseries_graph <- if(number_of_years>1){ggplot(data=params$Time_Data, aes(x=Year,y=Value)) +
geom_point(aes(color=Region_label), size=1.5) + geom_line(aes(color=Region_label), size=1.5) + scale_color_brewer(palette="Dark2") +
scale_x_continuous(breaks=seq(lower_year,higher_year, by=1)) +
labs(x="",y=measure)+ theme_minimal()} else {ggplot(data=params$Time_Data, aes(x=Year,y=Value)) +
geom_point(aes(color=Region_label), size=1.5) + scale_color_brewer(palette="Dark2") +
scale_x_continuous(breaks=seq(lower_year,higher_year, by=1)) +
labs(x="",y=measure)+ theme_minimal()}
print(timeseries_graph)
```