-
Notifications
You must be signed in to change notification settings - Fork 0
/
2_explore-counts.Rmd
102 lines (82 loc) · 2.16 KB
/
2_explore-counts.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
88
89
90
91
92
93
94
95
96
97
98
99
100
---
title: "Počty úředníků: 2013-2018"
author: "Petr Bouchal"
date: "11/2/2019"
output:
html_document:
df_print: paged
code_download: T
execute:
freeze: auto
---
```{r setup, echo = T, message=F, warning=F}
knitr::opts_chunk$set(echo = T, warning = F, message = F)
library(readr)
library(dplyr)
library(ggplot2)
library(tidyr)
```
```{r include=F}
dt <- read_rds("data-interim/objemy_pocty_scraped_raw_2012_2018.rds")
dt
```
# Basic counts by group {.tabset}
## Table
```{r}
dt %>%
filter(kap_num == "C E L K E M" & indicator == "count" &
year %in% c(2013, 2018)) %>%
filter(!(type %in% c("PO sum", "Příslušníci a vojáci"))) %>%
mutate(skutecnost = (round(skutecnost)/1e3) %>% round(1)) %>%
select(type, skutecnost, year) %>%
pivot_wider(names_from = year, values_from = skutecnost) %>%
select(type, `2013`, `2018`) %>% knitr::kable()
```
```{r include=T}
159.8 - 26.5 - 81.7
```
## Chart
```{r}
dt %>%
filter(kap_num == "C E L K E M" & indicator == "count" & year == 2018) %>%
filter(!(type %in% c("Příslušníci a vojáci"))) %>%
# mutate(skutecnost = (round(skutecnost)/1e3) %>% round(1)) %>%
# select(type, skutecnost)
select(type, skutecnost) %>% ggplot() + geom_col(aes(type, skutecnost)) +
coord_flip()
```
# Over time {.tabset}
## absolutes
```{r}
dt %>%
filter(kap_num == "C E L K E M" & indicator == "count") %>%
ggplot() +
geom_line(aes(x = year, y = skutecnost/1e3, group = type)) +
facet_wrap(~type)
```
## Change from 2013 base
```{r}
dt %>%
filter(kap_num == "C E L K E M" & indicator == "count") %>%
group_by(type) %>%
arrange(year) %>%
mutate(index = skutecnost/first(skutecnost)) %>%
ggplot() +
geom_line(aes(x = year, y = index, group = type)) +
facet_wrap(~type)
```
## Plan vs. reality
```{r}
dt %>%
filter(kap_num == "C E L K E M" & indicator == "count") %>%
ggplot() +
geom_line(aes(x = year, y = plneni, group = type)) +
facet_wrap(~type)
```
```{r}
dt %>%
filter(kap_num == "C E L K E M" & indicator == "cost") %>%
filter(year == 2018) %>%
select(rozp, skutecnost, year, type) %>%
mutate_at(vars(skutecnost, rozp), ~(./1e9) %>% round(1))
```