-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2017-data-bzh.R
123 lines (101 loc) · 3.33 KB
/
2017-data-bzh.R
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
118
119
120
121
library(tidyverse)
library(magrittr)
source("data-bzh-tools-master/main.R")
files <- list.files("../open-data/", pattern = "^2017", full.names = TRUE)
full <- map_df(files, read_csv)
full$heure %<>% as.POSIXct()
glimpse(full)
# Stats
full %>%
summarise(`Volume` = n(),
`Impressions Moyennes` = mean(impressions),
`Engagements Moyens` = mean(engagements),
`Retweets Moyens` = mean(Retweets),
`Réponses Moyens` = mean(réponses),
`J'aime Moyens` = mean(`J'aime`)) %>%
knitr::kable() %>%
clipr::write_clip()
full <- full %>% mutate(mois = lubridate::month(heure))
full %>%
group_by(mois) %>%
summarise(`Volume` = n(),
`Impressions Totales` = sum(impressions),
`Engagements Totaux` = sum(engagements),
`Retweets Totaux` = sum(Retweets),
`Réponses Totales` = sum(réponses),
`J'aime Totaux` = sum(`J'aime`)) %>%
knitr::kable() %>%
clipr::write_clip()
mois <- full %>%
group_by(mois) %>%
summarise(`Volume` = n(),
`Impressions Totales` = sum(impressions),
`Engagements Totaux` = sum(engagements),
`Retweets Totaux` = sum(Retweets),
`Réponses Totales` = sum(réponses),
`J'aime Totaux` = sum(`J'aime`))
ggplot(mois) +
aes(mois, Volume) +
geom_col(fill = databzh$colour1) +
labs(title = "Tweets par mois en 2018",
subtitle = "Données via Twitter",
caption = "http://data-bzh.fr") +
databzhTheme()
ggplot(mois) +
aes(mois, `Impressions Totales`) +
geom_col(fill = databzh$colour2) +
labs(title = "Impressions Totales par mois en 2018",
subtitle = "Données via Twitter",
caption = "http://data-bzh.fr") +
databzhTheme()
ggplot(mois) +
aes(mois, `Engagements Totaux`) +
geom_col(fill = databzh$colour3) +
labs(title = "Engagements Totaux par mois en 2018",
subtitle = "Données via Twitter",
caption = "http://data-bzh.fr") +
databzhTheme()
ggplot(mois) +
aes(mois, `Retweets Totaux`) +
geom_col(fill = databzh$colour4) +
labs(title = "Retweets Totaux par mois en 2018",
subtitle = "Données via Twitter",
caption = "http://data-bzh.fr") +
databzhTheme()
ggplot(mois) +
aes(mois, `Réponses Totales`) +
geom_col(fill = databzh$colour5) +
labs(title = "Réponses Totales par mois en 2018",
subtitle = "Données via Twitter",
caption = "http://data-bzh.fr") +
databzhTheme()
ggplot(mois) +
aes(mois, `J'aime Totaux`) +
geom_col(fill = databzh$colour6) +
labs(title = "J'aime Totaux par mois en 2018",
subtitle = "Données via Twitter",
caption = "http://data-bzh.fr") +
databzhTheme()
full <- full %>%
mutate(hash = str_extract_all(`Texte du Tweet`, "#[A-Za-z]* "))
# Hahstags
full %>%
unnest() %>%
select(hash) %>%
mutate(hash = tolower(hash)) %>%
count(hash, sort = TRUE) %>%
top_n(10) %>%
knitr::kable() %>%
clipr::write_clip()
# tweets les plus
full %>%
top_n(1, Retweets) %>%
select(`Identifiant du Tweet`, heure, Retweets, `Permalien du Tweet`) %>%
knitr::kable() %>%
clipr::write_clip()
# tweets les plus
full %>%
top_n(1, `J'aime`) %>%
select(`Identifiant du Tweet`, heure, `J'aime`, `Permalien du Tweet`) %>%
knitr::kable() %>%
clipr::write_clip()