-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSocial_SWISSIX_Vis.Rmd
66 lines (47 loc) · 1.64 KB
/
Social_SWISSIX_Vis.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
---
title: "covid19_soc_swissix"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(ggplot2)
library(dplyr)
library(statR)
```
## Data Import
```{r cars}
url_dat <- "https://raw.githubusercontent.com/CGRBZH/covid19_soc_swissix/master/Social_SWISSIX.csv"
data <- read_csv(url(url_dat))
```
## Visualization 1 - Daily volume
```{r vis daily, fig.height=8, fig.width=12, echo=FALSE}
ggplot(data, aes(x=date, y=value/8)) + geom_point(color = "#FF6666", alpha = 0.7) +
geom_path(color = "#FF6666", alpha = 0.7) +
scale_x_date(date_labels = "%a\n%d. %m", date_breaks = "1 week") +
labs(title = "Tägliches Internet-Datenvolumen | 01.01.-05.04.2020",
caption = "Quelle: SwissIX",
x = NULL,
y = "Terabyte") +
theme_stat() +
theme(panel.grid.major.x = element_line(linetype = "solid", size = 0.25, color = "grey"))
# ggsave("swissix_daily.png", width = 24, height = 8, units = "cm")
```
## Visualization 2 - Weekly Volume
```{r vis weekly, fig.height=8, fig.width=12}
# Data prep
data_wk <- data %>% select(date, value) %>%
mutate(week = format(date, '%Y-%V')) %>%
group_by(week) %>%
summarise(weekly_total = sum(value)) %>%
mutate(weekly_change = weekly_total - lag(weekly_total, default = first(weekly_total)))
ggplot(data_wk, aes(week)) +
geom_bar(aes(weight = weekly_total/8), fill = "#FF6666")+
labs(title = "Wöchentliches Internet-Datenvolumen | KW 1- KW 14, 2020",
caption = "Quelle: SwissIX",
x = NULL,
y = "Terabyte") +
ylim(c(0, 15000)) +
theme_stat()
# ggsave("swissix_weekly.png", width = 28, height = 18, units = "cm")
```