S. Hong, H. Berk, J. Hamski
27 May 2015
Twitter is a venue for professional skills development …
… not just a place to post cat pics and complain to airlines
library(twitteR)
setup_twitter_oauth(consumer_key,
consumer_secret,
access_token,
access_secret)
[1] "Using direct authentication"
#Who uses the #RStats hashtag the most?
r.stats.search <- searchTwitter("#Rstats", n=1000)
# For the top ten tweeters of the #RStats hashtag...
followers <- user$getFollowers(n=200)
favorites <- user$getFavorites(n=200)
(1) Play with API to know it's capabilities (2) Create a dummy dataset to plan out DB build (3) Go back to the API to get data in a reasonable format
sean <- c("nate", "matt", "sara", "pete", "laura")
laura <- c("maura", "sean", "greg", "matt", "sara")
albert <- c("nate", "sara", "roger", "maura")
add.rel <- function(flwr, user){
user = getOrCreateNode(graph, "Name", name=user)
flwr = getOrCreateNode(graph, "Name", name=flwr)
createRel(flwr, "FOLLOWS", user)}
user <- "sean"
a <- lapply(sean, FUN = add.rel, user = user)
add.rel.followers <- function(flwr, user){
user = getOrCreateNode(graph, "Name", name=user)
flwr = getOrCreateNode(graph, "Name", name=flwr)
createRel(flwr, "FOLLOWS", user)}
for (i in 1:length(users)){
a <- lapply(unlist(unname(followers[i])), FUN = add.rel.followers, user = users[i])}
add.rel.favorites <- function(flwr, user){
user = getOrCreateNode(graph, "Name", name=user)
flwr = getOrCreateNode(graph, "Name", name=flwr)
createRel(flwr, "FAVORITED", user)}
for (i in 1:length(users)){
a <- lapply(unlist(unname(favorites[i])), FUN = add.rel.favorites, user = users.fav[i])}