-
Notifications
You must be signed in to change notification settings - Fork 1
/
06_plotting.R
71 lines (64 loc) · 2.74 KB
/
06_plotting.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
writeLines("It is part of my CNPq-funded project and seeks to make corpus tools and R accessible. If you have any doubts or wish to make any research contact please send me an email. Rodrigo de Lima-Lopes [email protected]")
# Now we plot the presidents
# All in a single and simple command
presidents %>% rtweet::ts_plot("month", trim = 7L)
# Now each presindet
# **Jair Bolsonaro**
presidents %>%
dplyr::filter(created_at > "2022-01-01") %>%
dplyr::filter(screen_name == "jairbolsonaro") %>%
rtweet::ts_plot("day", trim = 7L) +
ggplot2::geom_point(color = "black",shape=21,fill="blue",size = 3) +
ggplot2::geom_line(color = "blue")+
ggplot2::theme_minimal() +
ggplot2::labs(
x = NULL, y = NULL,
title = "Frequency of Twitter statuses posted by Jair Bolsonaro",
subtitle = "Twitter status (tweet) counts aggregated by day from January 2022",
caption = "\nSource: Data collected from Twitter's REST API via rtweet"
)
# **Ciro Gomes**
presidents %>%
dplyr::filter(created_at > "2022-01-01") %>%
dplyr::filter(screen_name == "cirogomes") %>%
rtweet::ts_plot("day", trim = 7L) +
ggplot2::geom_point(color = "black",shape=21,fill="darkgreen",size = 3) +
ggplot2::geom_line(color = "darkgreen")+
ggplot2::theme_minimal() +
ggplot2::labs(
x = NULL, y = NULL,
title = "Frequency of Twitter statuses posted by Ciro Gomes",
subtitle = "Twitter status (tweet) counts aggregated by day from January 2022",
caption = "\nSource: Data collected from Twitter's REST API via rtweet"
)
# **Lula**
presidents %>%
dplyr::filter(created_at > "2022-01-01") %>%
dplyr::filter(screen_name == "LulaOficial") %>%
rtweet::ts_plot("day", trim = 7L) +
ggplot2::geom_point(color = "black",shape=21,fill="red",size = 3) +
ggplot2::geom_line(color = "red")+
ggplot2::theme_minimal() +
ggplot2::labs(
x = NULL, y = NULL,
title = "Frequency of Twitter statuses posted by Lula",
subtitle = "Twitter status (tweet) counts aggregated by day from January 2022",
caption = "\nSource: Data collected from Twitter's REST API via rtweet"
)
# All three
presidents %>%
dplyr::filter(created_at > "2021-08-01") %>%
dplyr::group_by(screen_name) %>%
rtweet::ts_plot("day", trim = 7L) +
ggplot2::geom_point(size = 3, aes(shape = factor(screen_name),color = factor(screen_name))) +
ggplot2::theme_minimal() +
ggplot2::theme(
legend.title = ggplot2::element_blank(),
legend.position = "bottom",
plot.title = ggplot2::element_text(face = "bold")) +
ggplot2::labs(
x = NULL, y = NULL,
title = "Frequency of Twitter statuses posted by Brazilian Presidential Pre-Candidates",
subtitle = "Twitter status (tweet) counts aggregated by date",
caption = "\nSource: Data collected from Twitter's REST API via rtweet"
)