-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_articles_frequencies_over_time.R
31 lines (23 loc) · 1.13 KB
/
plot_articles_frequencies_over_time.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
options(stringsAsFactors = FALSE)
library(quanteda)
library(dplyr)
library(tidyverse)
# Plot article frequencies over time
# Save the month and year of the date separately as a column
textdata_new$months <- format(as.Date(textdata_new$date), "%Y %m")
#head(textdata_new$months,5)
# aggregation of articles over months
articles_cnt <- count(textdata_new, textdata_new$months)
#head(articles_cnt,5)
colnames(articles_cnt) <- c('months', 'counts')
# control: sum of all articles
#articles_ges <- sum(articles_cnt$counts)
# barplot:
ggplot(articles_cnt, aes(months, counts)) + geom_bar(stat="identity")+ theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.2)) +
scale_y_continuous(name = "Number of articles") +
theme(axis.text=element_text(size=14),
axis.title=element_text(size=15,face="bold"))
#+ labs(title = "Number of Articles over time")
# alternative: dot plot
ggplot(articles_cnt, aes(date, counts)) + geom_point()+ theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.2)) +
scale_y_continuous(name = "Number of articles") + labs(title = "Number of Articles over time")