-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValidation.Rmd
118 lines (88 loc) · 2.34 KB
/
Validation.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
title: "Validation"
output:
html_document:
toc: true
toc_depth: 3
toc_float:
collapsed: true
smooth_scroll: true
theme: lumen
highlight: tango
---
<style type="text/css">
.main-container {
max-width: 1800px;
margin-left: 0;
margin-right: auto;
}
blockquote {
padding: 10px 20px;
margin: 0 0 20px;
font-size: 14px;
border-left: 5px solid #eee;
}
h1.title {
font-size: 38px;
color: #000000;
}
h1 { /* Header 1 */
font-size: 28px;
color: #0033cc;
}
h2 { /* Header 2 */
font-size: 28px;
color: #0099ff
}
h3 { /* Header 3 */
font-size: 14px;
color: #6600cc
}
</style>
```{r setup, echo=FALSE, results='hide', message=FALSE, warning=FALSE, width = 14}
# dir <- "C:/gitrepos/covid19monitoring_mobility_VerkehrsmessstellenKantonZH"
dir <- ("~/git/covid19monitoring_mobility_VerkehrsmessstellenKantonZH")
setwd(dir)
# import function
source("./function.R")
# import libraries
library(dplyr)
# library(readr)
# library(kableExtra)
# library(DT)
# library(lubridate)
library(ggplot2)
# import data
dat <-read.csv("./Mobility_VerkehrsmessstellenKantonZH.csv", header=T, sep=",", stringsAsFactors=FALSE, encoding="UTF-8")
# prepare data
dat_split <- dat %>%
group_split(variable_short) #%>%
#group_map(s(X))
```
# Unique Values
```{r, collapse=TRUE, warning=FALSE,message=FALSE, echo = FALSE}
lapply(dat_split, FUN = function(X) CheckIfDfFollowsStandard2(X))
```
# Plots
fig.height = 8
```{r, collapse=TRUE, warning=FALSE, message=FALSE, echo = FALSE, , out.width='\\textwidth', fig.width = 20, fig.height= 5}
theme_set(theme_gray(base_size = 18))
# create looping variable
sel <- unique(dat$variable_long)
for (i in 1:length(sel)) {
dat_plot <- dat %>%
filter(variable_long == sel[i]) %>%
mutate(date = lubridate::as_date(date))
p <- ggplot(dat_plot, aes(x=date, y=value)) + geom_point(alpha = 0.7) +
geom_path(alpha = 0.7) +
scale_x_date(date_labels = "%a\n%d. %m", date_breaks = "1 week") +
labs(title = paste(unique(dat_plot$variable_long), "|", unique(min(dat_plot$date)), "-", unique(max(dat_plot$date))),
caption = paste("Quelle:", unique(dat_plot$source)),
x = NULL,
y = "Anzahl Fahrzeuge") +
#theme_stat() +
theme(panel.grid.major.x = element_line(linetype = "solid", size = 0.25, color = "grey"))
# print plots to screen
print(p)
}
```