# Basic knitr options library(knitr) opts_chunk$set(comment = NA, echo = FALSE, warning = FALSE, message = FALSE, error = TRUE, cache = FALSE, fig.path = 'figures/')
# Libraries library(vilaweb) library(rtweet) library(tidyverse) library(databrew) library(translateR) library(sentimentr) # https://github.com/trinker/sentimentr
# Define function for improving timeline improve_timeline <- function(tmls){ tmls$time_only <- sapply(strsplit(substr(tmls$created_at, 11,19), ":"), function(x){as.numeric(x) %*% c(3600, 60, 1)}) tmls$time_only <- tmls$time_only / 3600 tmls$date <- as.Date(cut(tmls$created_at, 'day')) tmls$hour <- as.POSIXct(cut(tmls$created_at, 'hour')) return(tmls) }
file_name <- '155ya.RData' if(!file_name %in% dir()){ rt <- search_tweets( '"#155YA"', n = 1000000, include_rts = T, retryonratelimit = TRUE ) save(rt, file = file_name) } else { load(file_name) } message('---getting users') users <- lookup_users(users = unique(rt$user_id)) save(users, file = '155ya_users.RData') bots <- users %>% filter(followers_count <= 10) # tls <- get_timelines(bots$screen_name, n = 3200) # save(tls, bots, '155tls.RData') joined <- rt %>% left_join(users %>% dplyr::select(account_created_at, screen_name)) users$x <- cut(users$account_created_at, 'day') y <- users %>% group_by(x = as.Date(x)) %>% tally ggplot(data = y %>% filter(x >= '2018-07-10'), aes(x = x, y = n)) + geom_bar(stat = 'identity') users %>% filter(account_created_at >= '2018-12-18') # ggplot(data = tls %>% # filter(date >= '2017-01-01'), # aes(x = time_only, # # y = as.factor(date), # y = date)) + # geom_point(size = 0.2, # aes(color = screen_name)) + # # geom_density_ridges() + # theme_minimal() + # theme(legend.position = 'none') # # facet_wrap(~screen_name, # # scales = 'free') # # # Look at created_at, account_lang, # # profile_image_url: http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.