Original link:tecdat.cn/?p=3956 

Original source:Tuo End number according to the tribe public number

 

Twitter is a popular social network, and there’s a ton of data waiting to be analyzed. The Twitter R package is a great tool for text mining Twitter data. This article is about using the Twitter R package to take Twitter data, import it into R, and then do some interesting data analysis on it.

The first step is to register your app.

To be able to access Twitter data programming, we need to create an application that interacts with Twitter’s API.

After registering you will receive a key and password:

After obtaining the key and password, we can authorize our application in R to access Twitter on our behalf:

Depending on the search term, we can collect tens of thousands of tweets in a matter of minutes. Here we test the twitter results of a keyword called Littlecaesars:

Grab the latest 1000 related Tweets

Since the default crawl result is in JSON format, the twlisttodf function is used to convert it into a data box

Then we do some simple text cleaning

From the obtained data, we can see twitter Posting time, content, longitude and latitude and other information

After cleansing the data, we segmented the Twitter content for data visualization

After word segmentation, we can get the related twitter high-frequency words and then visualize them

In addition, the data can be combined with the timestamp data and geographic data for visual analysis

If you’ve been considering applying sentiment analysis to some textual data, you might find it easier to use R than you thought!