-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtag_stats.R
38 lines (27 loc) · 952 Bytes
/
tag_stats.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
library(dplyr)
library(purrr)
library(ggplot2)
library(stringr)
dump <- readRDS("data_dump.rds")
tags <- unlist(dump %>%
map(~ .x$content %>%
map(~ .x$f1000Tags)))
tag.stats <- tibble(channel = str_remove(names(tags),"\\d+"), tag = tags)
total.tag.counts <- tag.stats %>% group_by(tag) %>%
summarize(count = n())
ggplot(total.tag.counts, aes(x = reorder(tag, -count), y = count)) +
geom_point() +
scale_y_log10() +
xlab("Tag") +
ylab("Count") +
theme_classic() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
channel.tag.counts <- tag.stats %>% group_by(channel, tag) %>%
summarize(count = n())
ggplot(channel.tag.counts, aes(x = tag, y = count, fill = channel)) +
geom_bar(position="stack", stat="identity") +
xlab("Tag") +
ylab("Count") +
scale_fill_brewer(palette = "Set3") +
theme_classic() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))