Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Twitter data Mining in R
#install required packages
install.packages("twitteR")
install.packages("RCurl")
install.packages("httr")
install.packages("devtools")
devtools::install_github("r-lib/httr")
#Load necessary packages
library(twitteR)
library(RCurl)
library(base64enc)
#Go to http://dev.twitter.com/apps/new to create an app and get values
# for these credentials, which you'll need to provide in place of these
# empty string values that are defined as placeholders.
# See https://dev.twitter.com/docs/auth/oauth for more information
# on Twitter's OAuth implementation.
Access_token <- ""
Access_token_secret <- ""
consumer_key <- ""
consumer_secret <- ""
#Calling twitteR OAuth function
setup_twitter_oauth(consumer_key,consumer_secret,Access_token,Access_token_secret)
#Extracting Trends using getTrends Function
KE_WOE_ID = 23424863
current_trends <- getTrends(KE_WOE_ID)
View(current_trends)
#Get Tweets using userTimeline function
tweets <- userTimeline("so and so", 50)
#Get tweets from a certain trending topic
IEBC_Tweets <- searchTwitter("IEBC", n=100, lang = "en")
#convert the tweets into a df
tweets.df <-twListToDF(IEBC_Tweets)
dim(tweets.df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment