You can do a lot in the way of text analytics with Twitter. But in order to do so, first you need to connect with Twitter.
In order to do so, first you need to set up an account on Twitter and get an API key. Once you have created your account, go to the following website:Β https://dev.twitter.com/
Once there, click My apps
Click Create New App
Give name, description (it doesn’t matter – matter anything up), for website I just used http://test.de
Go to Keys and Access Tokens
Get your Consumer Key (API Key), Consumer Secret (API Secret), Access Token, and Access Token Secret
Now open R and install the TwitteR package.
install.packages("twitteR")
Now load the library
library(twitteR)
Next we are going to use the API keys you collected to authorize our connection to the Twitter API (Twitter uses OAuth by the way)
api_key<- "insert consumer key here" api_secret <- "insert consumer secret here" access_token <- "insert access token here" access_token_secret <- "insert access token secret here setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)
Now to test to see if your connection is good
searchTwitter('analytics')
Pingback: R: Twitter Sentiment Analysis – Analytics4All
Hi, I’m trying to do this, and have followed the instructions closely, but keep receiving an error message whenever I try to use searchTwitter, saying ‘could not find function “searchTwitter”‘
I have installed the twitteR library.
What am I doing wrong?
Samantha, sorry for the late reply. I just got home from work. If you are getting an error stating you cannot find function searchTwitter(), it must have something to do with the install of twitteR. The first question I have is are you running R from CRAN or are you using another version like Open R from Microsoft (not all versions support all R libraries). If you are running R from CRAN, I would suggest uninstalling the twitteR a library and reinstalling it. I’d throw in a reboot in between for good measure. The sad reality is, programmers spend wayyyy too much time troubleshooting problems.
hii
Thanks for your help, very helpful :3