Introduction


Social media has been utilized as an effective force by politicians, marketers, businesses, companies, and even people to achieve their aims once it became clear that it had the most influence on public opinion of any type of media. One of the world’s most popular portals that serves, among other things, to shape public opinion is Twitter, which was recently bought by Elon Musk. With the takeover of the company by the American businessman, there was a wave of negative comments about him, which negatively affected his reputation and business.

My paper will focus on assessing how opinion on him has changed based solely on Twitter posts. The purpose of this study, will be to see if the new business owner is using his new acquisition to improve the opinion about him by deleting posts that are negative from his point of view, or if he is allowing this opinion to form in a way that reflects the true feelings of the public.

Since using social media to shape public opinion is a very popular and frequently used tool, the results should indicate that after the acquisition of Twitter, the number of positive comments increased and the number of negative ones decreased, despite the fact that the general trend (Facebook, Instagram, News) was quite the opposite. To answer this question, Sentiment Analysis will be used for the study, which can detect positive or negative emotions based on text.

Data


The data was retrieved using an API from the tweepy package available in Python. Tweets in English that included the hashtag #elonmusk were downloaded. The data was divided by date into two parts - before the Twitter acquisition and after the acquisition (2022-10-28). In order to obtain reliable results, special attention was paid to obtaining a balanced dataset.

As a result, pre-acquisition tweets were published after 2022-04-14 and before 2022-10-28 (946 tweets), while post-acquisition tweets were published from 2022-10-28 and before 2023-01-17 (1000 tweets). The dataset eventually featured the following 8 columns:

  1. User
  2. Tweet - content
  3. Likes - number of likes
  4. Retweets - number of retweets
  5. Date - date of publication
  6. Location - location
  7. Author_followers - number of followers of authors
  8. Author_tweets - number of author’s tweets

To be able to perform sentiment analysis on this data, various transformations were applied to the initial tweets, which looked as follows:


User Tweet Likes Retweets Date Location Author_followers Author_tweets
Tommy_Jab @cryptojack Check out #RoboSquidToken just launched their first #P2E game! SAFE DEV! @RoboSquidToken 💎🔥🔥

Have fun playing and WIN the JACKPOT! 🎰💰🎯

#BSC #BNB #Binance #BTC #BITCOIN #ETH #BSCGem #BSCGemsAlert #SquidGrow #Crypto #FED #CPI #Crypto #SHIB #ElonMusk

https://t.co/mCl29iqREB | 0| 0|2022-10-26 23:59:56+00:00 | | 123| 2556| |Tommy_Jab |@cryptogems555 Check out #RoboSquidToken just launched their first #P2E game! SAFE DEV! @RoboSquidToken 💎🔥🔥

Have fun playing and WIN the JACKPOT! 🎰💰🎯

#BSC #BNB #Binance #BTC #BITCOIN #ETH #BSCGem #BSCGemsAlert #SquidGrow #Crypto #FED #CPI #Crypto #SHIB #ElonMusk

https://t.co/mCl29iqREB | 0| 0|2022-10-26 23:59:48+00:00 | | 123| 2556| |Tommy_Jab |@ChinaPumpWXC Check out #RoboSquidToken just launched their first #P2E game! SAFE DEV! @RoboSquidToken 💎🔥🔥

Have fun playing and WIN the JACKPOT! 🎰💰🎯

#BSC #BNB #Binance #BTC #BITCOIN #ETH #BSCGem #BSCGemsAlert #SquidGrow #Crypto #FED #CPI #Crypto #SHIB #ElonMusk

https://t.co/mCl29irpu9 | 0| 0|2022-10-26 23:59:39+00:00 | | 123| 2556|

Libraries used


Because the tweets contained a lot of special characters, spacing, links and emoji, it was processed to remove them and prepare them for analysis. For this and modeling purposes, following libraries were used:

library(tidytext)
library(tm)
library(dplyr)
library(stringr)
library(patchwork)
library(ggplot2)
library(tidyr)
library(wordcloud)
library(reshape2)

First, links and emoji were removed. As a next step, Tweet column was transformed to a corpus_text type so that the tm package can be used to automatically change words to lower case, remove punctuation, numbers, stopwords and spacing. Finally, tweets were ready for analysis and their final form was following:


User Tweet Likes Retweets Date Location Author_followers Author_tweets
2 warning515 daniels prophecy first beast lioness wings eagle fulfilled elon musks falcon heavy booster landing spacex elonmusk bookofdaniel prophecy falconheavy 0 0 2023-01-16 23:58:27+00:00 Ново-Огарёво (Basement) 21 1150
3 ElonMuskVids invested elonmusk said teslas stock price high heres 0 0 2023-01-16 23:58:05+00:00 USA 27 5011
4 ElonMuskVids elonmusks next drama trial tweets tesla sydney morning herald 0 0 2023-01-16 23:58:04+00:00 USA 27 5011
5 ElonMuskVids billionaire elonmusk faces trial tweets tesla york newstimes 0 0 2023-01-16 23:58:02+00:00 USA 27 5011

Modeling


As the tweets are ready to be compiled, they will be subjected to sentiment analysis to answer the question raised previously. At first, the nrc lexicon will be used, which can detect 8 different emotions. However, the most important for us were 2 of them, positive and negative.


It is clear how the emotional weight of opinion about Elon Musk changed after he took over Twitter. The most popular positive words occur in far greater numbers in the group of positive words and far fewer in the group of negative words after the acquisition. In particular:

  1. Most popular positive word (count) before - 53 and after - 218
  2. Most popular negative word (count) before - 52 and after - 12
  3. The most common positive words include (before) - found, deal, fun, safe, jackpot, full, join and (after) - experienced, love, good, happy, luck, idol, innovation. The first group is a mixture of expressions that do not have much in common and can occur in a sentence in various ways, not only positive (for example. found, deal, full, join). The other is full of words of a decidedly positive nature and suggesting that Elon Musk is a role model - idol, experienced, innovation.
  4. The most common negative words include (before) - lower, sure, violence, suspension, leave, losing and (after) - grab, mug, hate, liberal, exposed. While the first group may indicate criminal activity, the second is completely devoid of such associations.


As a next step, net sentiment was calculated in order to represent the described phenomenon in a numerical way. Bing lexicon was used in order to distinguish two different emotions category - positive and negative.

Period Negative Positive Sentiment
Before 510 604 94
After 282 1084 802

Calculated values also support the thesis presented at the beginning. Net sentiment is definitely higher after the Twitter acquisition. Again, the number of negative words in the total of all words decreased (from 46% to 21%) and the number of positive words increased (from 54% to 79%).

As a next step, word cloud charts were created in order to compare the most popular words in two periods. By showing the word frequency in the text as a weighted list, a word cloud is a fantastic tool for visual interpretation of literature and is helpful in swiftly getting insight into the most important elements in a particular text.

The most important words included in tweets before the takeover seemed to be associated with Twitter and crypto currencies. It is difficult to assess if the sentiment of this word cloud is shifting toward positive or negative as it is rather neutral.

This word cloud is more interesting as we can see that some new, very positive words appeared: experienced, love, potential, good, can, new. What is even more intriguing is that the word twitter seems to have less meaning here, whereas the opposite trend should be observed.

In order to see how the most important words were forming and compared two situations, word clouds that take into consideration the sentiment of words were created:

This visual indicates that the sentiment is shifted slightly more towards negative. However, the relationship is not very clear. We can see that the most important words are sink, racist, haters and sue, like, ready, fun, best, win, trump, which can be both, good or bad. Let’s take a look at the word cloud for tweets after the takeover:

Opposingly to the previous one, the sentiment here is very clear. In the group of tweets published after 28-10-22, very positive words were the most important ones - idol, love, luck, happy, best, good. While there are still some negative words, their importance is not big enough to outweight the positive group.


Evaluation


The results obtained are quite clear in terms of answering the question formulated in the beginning of the analysis. Almost every aspect of this research supported the thesis and, judging by how overwhelming the difference between these two data sets are, it is safe to say that the results are valid. Possible information loss can be hidden in hashtags - they are often a concatenation of many words and thus, difficult to examine. However, even with this additional information, the final results should not be too different from obtained in the course of this analysis and the conclusions should remain the same. To begin with, a tremendous amount of positive words appeared after Elon Musk’s takeover in comparison to what was before, whereas a big part of negative comments disappeared. Apart from this, the sentiment of tweets increased from 94 to 802 which is a huge change. Eventually, we can notice a clear shift from a neutral word cloud towards the one which is outweighted by very positive words. All in all, the results are very convincing and are a sufficient proof of the fact that Elon Musk uses twitter as a force that improves his public opinion.


Summary


In the course of analysis described, the most important thesis was found to be true. There is enough evidence for us to prove that comments on Elon Musk after taking over twitter were much more positive than before whereas the news and internet was full of critique on his actions.

Conclusions

Basing on the evidence presented above, the analysis can be concluded by following findings:

  1. Tweets about Elon Musk were manipulated with, as they shifted towards more positive right after he took over the company, whereas at the same time, there was a wave of critique aimed at him and his stocks were losing its value drastically.
  2. Negative tweets suggested criminal activity & lawsuit being filed against the businessman, apart from this, he’s accused of racism.
  3. At the same time, the new Twitter owner is known for his innovations and many people value his work and consider him an idol.
  4. Word ‘sink’ disappeared from tweets after the acquisition which could be a part of his strategy that was supposed to prevent his stocks from sinking.
  5. There are many leads that imply a close association between Donald Trump and Elon Musk.

Possible improvements.

  1. Handling glued together words in hashtags and abbreviations.
  2. Comparing this analysis with posts published on another, unbiased platform.
  3. Using more advanced techniques.