WARNING- this site includes words that may not be appropriate for younger R coders.

This Site will be a brief sentiment Analysis of Chick-fil-a and McDonald’s Based on Tweets Pulled from Twitter on November 15th , 2022.

NRC Lexicon Analysis

Generally, do people on twitter like Chick-Fil-A more than McDonalds?

To determine this, I will pull two sets of tweets using the words Chick-Fil-a and McDonald’s Respectfully. I will also use the NCR sentiment to determine if a more positive or negative words are said about each of these two fast food retailers.

rtweet_chickfila_tidy<-
  rtweet_Chickfila%>% 
  unnest_tokens(word,full_text) %>% 
  anti_join(stop_words)


rtweet_chickfila_tidy%>% 
  group_by(word) %>%
  summarise(n=n()) %>% 
  inner_join(nrc)%>%
  filter(n > 50) %>%
  filter(!word== 'chicken') %>% 
  filter(!word=='food') %>% 
  mutate(n = ifelse(sentiment == "negative", -n, n)) %>%
  mutate(word = reorder(word, n)) %>%
  ggplot(aes(word, n, fill = sentiment)) +
  geom_col() +
  coord_flip() +
  labs(y = "Contribution to sentiment")+
  ggtitle("Chick-fil-A NRC Sentiment Analysis Words from Recent Tweets")

This Code Removes Stop words, Joins the NRC Sentiments to the data and outputs a graph of the words and their NRC sentiment. These words must have been written or tweeted 50 times. I removed chicken and food because they were redundant.

rtweet_McDonalds_tidy<-
  rtweet_McDonalds%>% 
  unnest_tokens(word,full_text) %>% 
  anti_join(stop_words)

rtweet_McDonalds_tidy %>% 
  group_by(word) %>% 
  summarise(n=n()) %>% 
  inner_join(nrc)%>%
  filter(n > 50) %>%
  filter(!word=='food') %>% 
  mutate(n = ifelse(sentiment == "negative", -n, n)) %>%
  mutate(word = reorder(word, n)) %>%
  ggplot(aes(word, n, fill = sentiment)) +
  geom_col() +
  coord_flip() +
  labs(y = "Contribution to sentiment")+
  ggtitle("Mcdonald's NRC Analysis Words from Recent Tweets")

This Code Removes Stop words, Joins the NRC Sentiments to the data and outputs a graph of the words and their NRC sentiment. These words must have been written or tweeted 50 times. I removed food because they were redundant.

Conclusion

In conclusion, the Chick-fil-a sentiment analysis returned mostly positive with the word “chicken showing in a negative sentiment. I ended up removing this because it was not understanding chicken as food. Moreover, On the contrary, the McDonald’s sentiments were all over the place. Some where also pretty positive. Thus, it is hard to say from this graph that one is better than the other. Rather, I would say that they are both good but in different ways.

Bing Analysis per week Day

Does Chickfila have less positive tweets on Sunday compared to McDonald?

I will collect data from twitter for this analysis (same as last quere). I intend to detrmine this by making a bar graph of the positive and negative words said about Chickfila and McDonald’s using the Bing Lexicon sentiments. I will also make a bar graph using days of the week which I will mutate to the data frame.

McDonald’s bing Analysis

#Join bing to McDonalds Count# 

mcdonalds_bing<-
  rtweet_McDonalds_tidy %>% 
  group_by(word, created_at) %>% 
  summarise(n=n()) %>% 
  inner_join(bing)
  
  mcdonalds_bing %>%
    mutate(WeekDay = wday(created_at,label = TRUE,abbr = FALSE)) %>%
    group_by(WeekDay) %>%
    summarize(`Number of Positive` = sum(sentiment == "positive"),
              `Number of Negative`= sum(sentiment == "negative"))%>% 
    pivot_longer(cols = -"WeekDay", names_to = "Positive or Negative", values_to = "Count") %>% 
    ggplot(aes(x = (WeekDay), y = Count, fill= `Positive or Negative`)) +
    geom_col() +
    labs(x = "WeekDay", y = "Number of words")+
    ggtitle("Seniments Analysis of words from Tweets about Mcdonald's")

Conclusion

In the past three days, McDonald’s was most discussed on Monday. I am assuming this is because people would consume the food more often on Monday’s when there is generally lots of work going on and people need the quick fix of fast food. I also thought it was interesting that it appears that more tweets lead to more negative words. Maybe the service was poor on Monday because the employees were more busy.

Chick-fil-a bing Analysis

chickfila_bing<-
  rtweet_chickfila_tidy %>% 
  group_by(word, created_at) %>% 
  summarise(n=n()) %>% 
  inner_join(bing)

chickfila_bing %>%
  mutate(WeekDay = wday(created_at,label = TRUE,abbr = FALSE)) %>%
  group_by(WeekDay) %>%
  summarize(`Number of Positive` = sum(sentiment == "positive"),
            `Number of Negative`= sum(sentiment == "negative"))%>% 
  pivot_longer(cols = -"WeekDay", names_to = "Positive or Negative", values_to = "Count") %>% 
  ggplot(aes(x = (WeekDay), y = Count, fill= `Positive or Negative`)) +
  geom_col() +
  labs(x = "WeekDay", y = "Number of words") +
  ggtitle("Seniments Analysis of words from Tweets about Chickfila")

### Conclusion ###

For Chickfila, out of 2878 tweets none were made on Monday! This was crazy to me. Additionally I expected the number of words to be higher on days the company was closed assuming more people would be mad that they were closed. This was sort of the case. Generally, Sunday’s chickfila saw more negative words. I was also surprised to see that Saturday people were talking about chickfila a lot. Similar to the Mcdonald’s analysis I saw that more words lead to a more negative sentiment. I am really not sure why this occurred but I assume that this is likely due to things like sarcasm and twitter jargon that may be interpreted as negative but is possibly being misunderstood. In conclusion though, there did not appear to be a difference between sentiments for McDonalds and chick-fil-a on Sundays. It may be interesting to add more tweets to find a more significant difference.

Analysis using Afinn

what are the worst words being used in tweets about Mcdonalds and Chickfila?

To find this, I will use the tweets I pulled from earlier and utilize the afinn lexicon to quantify which words are the most negative.

rtweet_chickfila_tidy %>% 
  group_by(word) %>% 
  summarise(n=n()) %>% 
  inner_join(afinn) %>%  
  filter(value < -3)
## # A tibble: 21 × 3
##    word         n value
##    <chr>    <int> <dbl>
##  1 ass         31    -4
##  2 asshole      2    -4
##  3 bitch       13    -5
##  4 bitches      4    -5
##  5 bullshit     1    -4
##  6 damn        43    -4
##  7 damned       1    -4
##  8 dick         3    -4
##  9 fraud        1    -4
## 10 fuck        29    -4
## # … with 11 more rows

These are the top negative words used in the tweets. I found it particular interesting that most of these were cuss words. I believe this would better understood in context so I will include the ngrams.

rtweet_chickfila_tidy %>%
  unnest_tokens(sentences, text, token = "sentences") %>% 
  select(sentences) %>% 
  filter(grepl('bitch', sentences))
## # A tibble: 210 × 1
##    sentences                                                                    
##    <chr>                                                                        
##  1 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
##  2 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
##  3 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
##  4 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
##  5 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
##  6 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
##  7 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
##  8 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
##  9 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
## 10 "getting paid be making me feel like a brand new bitch\U0001f92a like yes si…
## # … with 200 more rows

I found that many of the cuss words are actually used in a positive context. For example, “a sip of that B**** was no joke.” This inciated to me that my earlier analysis on the positive and negative words may not be super accurate. Moreover, I believe that some of the negative words in the afinn lexicon can be negative but they are not always negative.

rtweet_McDonalds_tidy %>% 
  group_by(word) %>% 
  summarise(n=n()) %>% 
  inner_join(afinn) %>%  
  filter(value < -3)
## # A tibble: 25 × 3
##    word         n value
##    <chr>    <int> <dbl>
##  1 ass         50    -4
##  2 asshole      2    -4
##  3 bastard      1    -5
##  4 bitch       12    -5
##  5 bitches      2    -5
##  6 bullshit     6    -4
##  7 cock         1    -5
##  8 cunt         1    -5
##  9 damn        12    -4
## 10 damnit       1    -4
## # … with 15 more rows
rtweet_McDonalds_tidy %>%
  unnest_tokens(sentences, text, token = "sentences") %>% 
  select(sentences) %>% 
  filter(grepl('bitch', sentences))
## # A tibble: 151 × 1
##    sentences                          
##    <chr>                              
##  1 putins a disgusting son of a bitch.
##  2 putins a disgusting son of a bitch.
##  3 putins a disgusting son of a bitch.
##  4 putins a disgusting son of a bitch.
##  5 putins a disgusting son of a bitch.
##  6 putins a disgusting son of a bitch.
##  7 putins a disgusting son of a bitch.
##  8 putins a disgusting son of a bitch.
##  9 putins a disgusting son of a bitch.
## 10 putins a disgusting son of a bitch.
## # … with 141 more rows

In the case of McDonald’s the brand is used in a more negative context. When people refereed to it. The used McDonalds in a more negative tonality. For example “do I look like McDonalds type of b****”. In this case and many others I see the true more normal use of the cuss word.

Conclusion

It appears that the Chick-fil-A is, in general, is precieve much more positively in recent tweets in comparison to Mcdonalds. McDonald’s has a very bad tonality. It appear to be used as a adjective for something bad. This to me helped confirm that twitter users think more highly of Chick-Fil-A than McDonalds.