-->

Jendela Statistika

Melihat Dunia Dengan Data Sebagai Sebuah Investasi

WAYS COLLECTING DATA FROM TWITTER USING R


Hallo,..

Long time no write in my blog.
Today, I will start writing about the collection of data from twitter using R

Before collecting data from twitter with the help of R,
First we do the preparation :

The first step is to register in the twitter application developer’s portal and get the authorization. You need code Twitter API
api_key=  "your api key"
api_secret= "your api_secret password"
access_token= "your access token"
access_token_secret= "your access token password"
Second step is Install and Activate Packages in R
library(twitteR)
Okay, preparations are done and we'll get started how to collect data from twitter.
The first step is to invoke the authority of a twitter account, by using coding in r
api_key=  "your api key"api_secret= "your api_secret password"access_token= "your access token"access_token_secret= "your access token password"
After obtaining credentials, we setup authorizations to access twitter API.
setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)
Okay, next we can take a tweet data we want
tweets <- searchTwitter("ahok", n=1000, lang="en", since="2017-02-5", until='2017-02-08')
Until we've done this step of collecting data from twitter as much as 1000 tweet.

And then we can also use this function in collecting data on twitter:
TweetFrame = function(searchTerm, maxTweets)

{
  tweetList = searchTwitter(searchTerm,n=maxTweets)

  return(do.call("rbind",lapply(tweetList,as.data.frame)))

}
tweetsf = TweetFrame("k", n)


process of collecting data on twitter I can do.
This might be a new I learned about how data collection on twitter using R. 

hopefully helpful.

Baca juga:

0 komentar



Emoticon