1. Import the Nike Data

file_name <- "Nike_Social media Analysis complete (1)-1 (1).xlsx"

nike_posts <- read_excel(file_name, sheet = "Raw Data")

dim(nike_posts)
## [1] 100  25
names(nike_posts)
##  [1] "uri"              "cid"              "author_handle"    "author_name"     
##  [5] "text"             "author_data"      "post_data"        "embed_data"      
##  [9] "reply_count"      "repost_count"     "like_count"       "quote_count"     
## [13] "bookmark_count"   "indexed_at"       "created_at"       "in_reply_to"     
## [17] "in_reply_root"    "quotes"           "tags"             "mentions"        
## [21] "links"            "langs"            "labels"           "Engagement"      
## [25] "Sentiment Sample"
head(nike_posts)
## # A tibble: 6 × 25
##   uri     cid   author_handle author_name text  author_data post_data embed_data
##   <chr>   <chr> <chr>         <chr>       <chr> <chr>       <chr>     <chr>     
## 1 at://d… bafy… realmadrid-f… Real Madri… "⚽ O… "did:plc:z… "app.bsk… "list(uri…
## 2 at://d… bafy… fcbarcelona-… FC Barcelo… "⚽ O… "did:plc:t… "app.bsk… "list(uri…
## 3 at://d… bafy… swooshsupply… swoosh sup… "Nik… "did:plc:n… "app.bsk… "list(ima…
## 4 at://d… bafy… hnkbae.bsky.… > 𝘉𝘢𝘦.      "Ah,… "did:plc:z… "app.bsk…  <NA>     
## 5 at://d… bafy… goods.wouldc… goods       "Nik… "did:plc:7… "app.bsk… "list(uri…
## 6 at://d… bafy… sneakerscout… <NA>        "Nik… "did:plc:w… "app.bsk… "list(lis…
## # ℹ 17 more variables: reply_count <dbl>, repost_count <dbl>, like_count <dbl>,
## #   quote_count <dbl>, bookmark_count <dbl>, indexed_at <chr>,
## #   created_at <chr>, in_reply_to <chr>, in_reply_root <chr>, quotes <chr>,
## #   tags <chr>, mentions <lgl>, links <chr>, langs <chr>, labels <lgl>,
## #   Engagement <dbl>, `Sentiment Sample` <chr>

2. Clean and Prepare the Data

nike_clean <- nike_posts %>%
  mutate(
    text = as.character(text),
    author_handle = as.character(author_handle),
    created_at = ymd_hms(as.character(created_at), quiet = TRUE),
    like_count = replace_na(as.numeric(like_count), 0),
    repost_count = replace_na(as.numeric(repost_count), 0),
    reply_count = replace_na(as.numeric(reply_count), 0),
    quote_count = replace_na(as.numeric(quote_count), 0),
    bookmark_count = replace_na(as.numeric(bookmark_count), 0),
    engagement = like_count + repost_count,
    post_text_clean = text %>%
      str_to_lower() %>%
      str_replace_all("https?://\\S+", " ") %>%
      str_replace_all("@[\\w.-]+", " ") %>%
      str_replace_all("#[\\p{L}\\w_]+", " ") %>%
      str_replace_all("[^\\p{L}\\s]", " ") %>%
      str_squish()
  )

text_posts <- nike_clean %>%
  filter(!is.na(text), text != "", post_text_clean != "")

dim(nike_clean)
## [1] 100  27
head(nike_clean)
## # A tibble: 6 × 27
##   uri     cid   author_handle author_name text  author_data post_data embed_data
##   <chr>   <chr> <chr>         <chr>       <chr> <chr>       <chr>     <chr>     
## 1 at://d… bafy… realmadrid-f… Real Madri… "⚽ O… "did:plc:z… "app.bsk… "list(uri…
## 2 at://d… bafy… fcbarcelona-… FC Barcelo… "⚽ O… "did:plc:t… "app.bsk… "list(uri…
## 3 at://d… bafy… swooshsupply… swoosh sup… "Nik… "did:plc:n… "app.bsk… "list(ima…
## 4 at://d… bafy… hnkbae.bsky.… > 𝘉𝘢𝘦.      "Ah,… "did:plc:z… "app.bsk…  <NA>     
## 5 at://d… bafy… goods.wouldc… goods       "Nik… "did:plc:7… "app.bsk… "list(uri…
## 6 at://d… bafy… sneakerscout… <NA>        "Nik… "did:plc:w… "app.bsk… "list(lis…
## # ℹ 19 more variables: reply_count <dbl>, repost_count <dbl>, like_count <dbl>,
## #   quote_count <dbl>, bookmark_count <dbl>, indexed_at <chr>,
## #   created_at <dttm>, in_reply_to <chr>, in_reply_root <chr>, quotes <chr>,
## #   tags <chr>, mentions <lgl>, links <chr>, langs <chr>, labels <lgl>,
## #   Engagement <dbl>, `Sentiment Sample` <chr>, engagement <dbl>,
## #   post_text_clean <chr>

3. Linear Regression

simple_data <- nike_clean %>%
  select(like_count, repost_count)

simple_model <- lm(
  repost_count ~ like_count,
  data = simple_data
)

summary(simple_model)
## 
## Call:
## lm(formula = repost_count ~ like_count, data = simple_data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.14538 -0.00294 -0.00294 -0.00294  0.96145 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 0.002935   0.014824   0.198    0.843    
## like_count  0.035611   0.005308   6.709 1.27e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1426 on 98 degrees of freedom
## Multiple R-squared:  0.3148, Adjusted R-squared:  0.3078 
## F-statistic: 45.01 on 1 and 98 DF,  p-value: 1.27e-09
ggplot(simple_data, aes(x = like_count, y = repost_count)) +
  geom_point() +
  geom_smooth(method = "lm", se = TRUE) +
  labs(
    title = "Simple Linear Regression: Likes vs. Reposts",
    x = "Like Count",
    y = "Repost Count"
  ) +
  theme_minimal()

4. Descriptive Statistics and Engagement

engagement_summary <- nike_clean %>%
  summarise(
    total_posts = n(),
    total_likes = sum(like_count, na.rm = TRUE),
    total_reposts = sum(repost_count, na.rm = TRUE),
    total_replies = sum(reply_count, na.rm = TRUE),
    total_quotes = sum(quote_count, na.rm = TRUE),
    total_bookmarks = sum(bookmark_count, na.rm = TRUE),
    average_likes = round(mean(like_count, na.rm = TRUE), 2),
    average_reposts = round(mean(repost_count, na.rm = TRUE), 2),
    average_engagement = round(mean(engagement, na.rm = TRUE), 2),
    highest_engagement = max(engagement, na.rm = TRUE)
  )

engagement_summary %>%
  kable(caption = "Nike Social Media Engagement Summary")
Nike Social Media Engagement Summary
total_posts total_likes total_reposts total_replies total_quotes total_bookmarks average_likes average_reposts average_engagement highest_engagement
100 76 3 9 2 0 0.76 0.03 0.79 26

5. Top 10 Posts by Engagement

top_posts <- nike_clean %>%
  arrange(desc(engagement)) %>%
  slice_head(n = 10) %>%
  mutate(post_number = paste("Post", row_number())) %>%
  select(
    post_number,
    author_handle,
    text,
    like_count,
    repost_count,
    engagement
  )

top_posts %>%
  kable(caption = "Top 10 Posts by Engagement")
Top 10 Posts by Engagement
post_number author_handle text like_count repost_count engagement
Post 1 roryblank.bsky.social I mean I don’t know that Travis Knight, Nike scion, is hurting for money, but Laika movies are extremely time and labor intensive endeavors and they spent $100 million dollars making a stop motion movie, and by they, I mean also he’s the producer and head of the company that produced it. 25 1 26
Post 2 ricardooliveria2.bsky.social 🔥 Tênis Nike Mc Trainer 3

🚨 De R$ 599 por R$ 289 🎟️ Use o Cupom: MODA2310

🔗 https://meli.la/2qL9VCU

#amazon #Afazenda #Jonatas #desconto #promo | 4| 0| 4| |Post 3 |promoatomicas.bsky.social |🔥 Tênis Nike Mc Trainer 3

🚨 De R$ 599 por R$ 289 🎟️ Use o Cupom: MODA2310

🔗 https://meli.la/2qL9VCU

#mercadolivre #amazon #Afazenda #oferta #blackfriday | 4| 0| 4| |Post 4 |ricardooliveria2.bsky.social |🔥 Tênis Nike Uplift Sc Masculino

🚨 R$ 266 🎟️ Cupom: MODA2310

🔗 https://meli.la/1PZ54Me

#Revelando #amazon #SDV #desconto #oferta | 4| 0| 4| |Post 5 |promoatomicas.bsky.social |🔥 Tênis Nike Uplift Sc Masculino

🚨 R$ 266 🎟️ Cupom: MODA2310

🔗 https://meli.la/1PZ54Me

#Afazenda #SDV #Entregou #promoção #oferta | 4| 0| 4| |Post 6 |jakeythesnakey.bsky.social |If you are as grossed out by having Nike/Blazers advertising on the Portland White Stag sign as I am, I really recommend writing your councilors about it. I did, and I’m 3 for 3 on really nice responses from them.

Lmk if you want draft text. | 4| 0| 4| |Post 7 |eldritchmoon.love |- At the first president conference scene, the camera is angled in a way that ONLY shows digger’s white Nike sneakers but no one else’s shoes - also at that conference when they all lean in to look at the graph, there’s one guy so short he has to stand up to get a look | 3| 0| 3| |Post 8 |lunanomaly.bsky.social |🐍 we are so absolutely normal about the art of bat nike | 2| 1| 3| |Post 9 |caiaoobrabo.bsky.social |🔥 Tênis Nike Mc Trainer 3

🚨 De R$ 599 por R$ 289 🎟️ Use o Cupom: MODA2310

🔗 https://meli.la/2qL9VCU

#amazon #mercadolivre #Deltan #achadinhos #promo | 3| 0| 3| |Post 10 |pedrohenriquee353.bsky.social |🔥 Tênis Nike Mc Trainer 3

🚨 De R$ 599 por R$ 289 🎟️ Use o Cupom: MODA2310

🔗 https://meli.la/2qL9VCU

#SDV #Jonatas #mercadolivre #cupom #oferta | 3| 0| 3|

6. Text Analysis: Most Common Words

words <- text_posts %>%
  select(post_text_clean) %>%
  unnest_tokens(word, post_text_clean)

data("stop_words")

word_counts <- words %>%
  anti_join(stop_words, by = "word") %>%
  filter(str_length(word) > 2) %>%
  count(word, sort = TRUE)

top_words <- word_counts %>%
  slice_head(n = 20)

top_words %>%
  kable(caption = "Most Common Words")
Most Common Words
word n
nike 108
air 21
tênis 19
cupom 18
por 18
moda 17
chez 15
masculino 11
mercado 11
livre 10
pour 10
size 9
check 8
white 8
heritage 7
octobre 7
uplift 7
www 7
dans 6
force 6
ggplot(top_words, aes(x = reorder(word, n), y = n)) +
  geom_col() +
  coord_flip() +
  labs(
    title = "Most Common Words in Nike Posts",
    x = "Word",
    y = "Frequency"
  ) +
  theme_minimal()

7. Automated Sentiment Analysis

bing_words <- get_sentiments("bing")

sentiment_matches <- words %>%
  inner_join(bing_words, by = "word")

automated_sentiment <- sentiment_matches %>%
  count(sentiment, name = "word_matches") %>%
  mutate(
    percentage = round(
      word_matches / sum(word_matches) * 100, 2
    )
  )

automated_sentiment %>%
  kable(caption = "Automated Sentiment Analysis")
Automated Sentiment Analysis
sentiment word_matches percentage
negative 14 22.95
positive 47 77.05
ggplot(
  automated_sentiment,
  aes(x = sentiment, y = word_matches)
) +
  geom_col() +
  labs(
    title = "Automated Sentiment Analysis",
    x = "Sentiment",
    y = "Word Matches"
  ) +
  theme_minimal()

8. Positive and Negative Words

sentiment_word_counts <- sentiment_matches %>%
  count(sentiment, word, sort = TRUE)

positive_words <- sentiment_word_counts %>%
  filter(sentiment == "positive") %>%
  slice_head(n = 10)

negative_words <- sentiment_word_counts %>%
  filter(sentiment == "negative") %>%
  slice_head(n = 10)

positive_words %>%
  kable(caption = "Most Common Positive Words")
Most Common Positive Words
sentiment word n
positive available 9
positive uplift 7
positive cool 2
positive elite 2
positive nice 2
positive premier 2
positive spotless 2
positive well 2
positive appreciate 1
positive clean 1
negative_words %>%
  kable(caption = "Most Common Negative Words")
Most Common Negative Words
sentiment word n
negative dick 2
negative disagree 2
negative bitch 1
negative boycott 1
negative defy 1
negative evil 1
negative freak 1
negative hurting 1
negative leak 1
negative prejudice 1

9. Manual Sentiment Analysis

manual_sample <- read_excel(
  file_name,
  sheet = "Sentiment Sample",
  skip = 2
) %>%
  select(1:5)

names(manual_sample) <- c(
  "raw_row",
  "author",
  "post_text",
  "sentiment",
  "coding_rationale"
)

manual_sample <- manual_sample %>%
  filter(!is.na(sentiment)) %>%
  mutate(
    sentiment = str_to_title(as.character(sentiment))
  )

manual_summary <- manual_sample %>%
  count(sentiment, name = "posts") %>%
  mutate(
    percentage = round(
      posts / sum(posts) * 100, 2
    )
  )

manual_summary %>%
  kable(caption = "Manual Sentiment Results")
Manual Sentiment Results
sentiment posts percentage
Negative 2 13.33
Neutral 5 33.33
Positive 8 53.33

10. Interactive Plotly Chart

plot_data <- nike_clean %>%
  arrange(desc(engagement)) %>%
  slice_head(n = 10) %>%
  mutate(
    post_number = paste("Post", row_number()),
    hover_label = paste0(
      "Author: ", author_handle,
      "<br>Likes: ", like_count,
      "<br>Reposts: ", repost_count,
      "<br>Engagement: ", engagement,
      "<br>", text
    )
  )

fig <- plot_ly(
  data = plot_data,
  x = ~post_number,
  y = ~engagement,
  type = "bar",
  text = ~engagement,
  hovertext = ~hover_label,
  hoverinfo = "text"
) %>%
  layout(
    title = "Top 10 Nike Posts by Engagement",
    xaxis = list(title = "Post"),
    yaxis = list(title = "Likes + Reposts")
  )

fig

11. Findings and Interpretation

Use the tables and charts to explain engagement patterns, common words, and sentiment results. Automated sentiment analysis counts positive and negative words, while manual sentiment analysis evaluates individual posts. These methods may produce different results because they measure sentiment differently.

12. Critique of AI Output and Human Judgment

AI can help generate R code and explain statistical methods, but the results should always be checked against the original data. Human judgment is important when interpreting social media posts because automated sentiment analysis may not understand sarcasm, context, or different languages.

13. AI Prompts Used

Original Prompt:

“Help me analyze my Nike social media Excel data using R. I need to clean the data, analyze engagement and sentiment, and create charts.”

Improved Prompt:

“Analyze my Nike social media Excel dataset using RStudio. Clean the data, calculate engagement, perform linear regression, identify the most common words, conduct sentiment analysis, compare automated and manual sentiment results, and create an interactive Plotly chart. Explain the results and limitations of the analysis.”