Reference: https://jsta.rbind.io/blog/making-a-twitter-dashboard-with-r/
## Registered S3 method overwritten by 'openssl':
## method from
## print.bytes Rcpp
# display data table:
my_likes %>%
datatable(extensions = 'Buttons',
options = list(dom = 'Bfrtip',
buttons = c('excel', "csv"),
pageLength = 20)) %>%
formatStyle(columns = colnames(.), fontSize = '20%')
## Warning in instance$preRenderHook(instance): It seems your data is too
## big for client-side DataTables. You may consider server-side processing:
## https://rstudio.github.io/DT/server.html
## Whose tweets do I like most?
```r
top_accounts <-
my_likes %>%
count(screen_name,
followers_count,
sort = TRUE) %>%
mutate(proportion = n/sum(n)) %>%
rename(likes_since_dec_2018 = n)
top_accounts %>%
datatable() %>%
formatRound(4, 3)
```
```r
# graph the relationship
p1 <-
top_accounts %>%
ggplot(aes(x = followers_count,
y = likes_since_dec_2018,
group = screen_name)) +
geom_point() +
scale_x_log10(breaks = trans_breaks(trans = "log10",
inv = function(x){10^x},
n = 10),
labels = trans_format(trans = "log10",
math_format(10^.x))) +
scale_y_log10() +
labs(title = "My likes on Twitter",
subtitle = "The accounts I like most are neither unknown nor too popular, mostly focusing on statistics, Rn 1K followers is probably too niche/inactive; more than 100K probably doesn’t focus on interest areas”) +
theme_light() +
theme(panel.grid.minor = element_line(colour = "grey95"),
panel.grid.major = element_line(colour = "grey95")); p1
<img src="twitter-dashboard_files/figure-html/graph-1.png" width="672" />
```r
# ggplotly(p1)