Reflection

For this lab, AI was used to help organize an R Markdown file, clean the BlueSky data, count common words, calculate sentiment scores, and create an interactive chart. The useful part of AI assistance was turning the assignment into clear steps with code that can be checked. However, AI output still needs review. A word-based sentiment score does not automatically tell us how someone feels about Nike. The dataset includes advertisements, different languages, and posts that use the word Nike to mean something other than the shoe company. These examples show why an organized report can still lead to a misleading conclusion if the results are accepted without checking the original text.

Human judgment is needed to decide which posts answer the research question and whether the sentiment labels make sense in context. For example, “Cool Grey” is a shoe color, not necessarily a positive opinion, and a post about a Nike missile site is not about the brand. An English sentiment dictionary also cannot fully explain posts in other languages, sarcasm, or opinions directed at someone else. The report therefore separates posts with no dictionary matches from posts with equal positive and negative counts, includes checks of the cleaning steps and score calculations, and limits the conclusions to this sample. AI can help with the code, but people still need to check the evidence and explain the limits of the analysis.

Research question and data

What words occur most often in this BlueSky sample, and what positive and negative word patterns appear when an English sentiment dictionary is applied?

The input is Scrape1_2026-10-22 (2).csv, supplied for this assignment. The filename is not used as proof of when individual posts were written. This is a descriptive analysis of the supplied sample, not an estimate of all customers’ opinions. No language, date, or representative sampling information is assumed.

The analysis uses tidytext for tokenization and its included Bing lexicon for positive and negative word labels. It uses plotly for the interactive chart. The Bing lexicon is a word dictionary; it does not interpret whole sentences or determine the target of an opinion.

1. Import and clean the data

Keep this Rmd and the CSV in the same Posit Cloud folder. The import reads all columns as text so that identifiers are preserved.

csv_file <- "Scrape1_2026-10-22 (2).csv"
if (!file.exists(csv_file)) {
  stop("Upload ", csv_file, " into the same folder as this Rmd file.")
}

raw_posts <- readr::read_csv(
  csv_file,
  col_types = cols(.default = col_character()),
  na = c("", "NA"),
  locale = locale(encoding = "UTF-8"),
  show_col_types = FALSE,
  progress = FALSE
)
required_columns <- c("uri", "author_handle", "text")
if (!all(required_columns %in% names(raw_posts))) {
  stop("The CSV must contain: ", paste(required_columns, collapse = ", "))
}

raw_posts <- raw_posts %>%
  mutate(post_id = row_number(),
         text_raw = coalesce(text, ""))

nonblank_posts <- raw_posts %>%
  filter(str_squish(text_raw) != "")

# Remove repeated post IDs, but retain separate posts with identical text.
# If an ID is absent, use that row's unique number as its key.
posts <- nonblank_posts %>%
  mutate(post_key = if_else(is.na(uri) | str_trim(uri) == "",
                            paste0("missing-id-row-", post_id), uri)) %>%
  distinct(post_key, .keep_all = TRUE)

clean_text <- function(x) {
  x %>%
    str_replace_all(fixed("\\n"), " ") %>%
    str_replace_all(fixed("\\r"), " ") %>%
    str_replace_all(c("&amp;" = "&", "&lt;" = "<", "&gt;" = ">")) %>%
    str_remove_all(regex("https?://\\S+|www\\.\\S+", ignore_case = TRUE)) %>%
    str_remove_all(regex("\\b[[:alnum:]][[:alnum:].-]*\\.[[:alpha:]]{2,}(?:/\\S*)?",
                         ignore_case = TRUE)) %>%
    str_remove_all("@[[:alnum:]_.-]+") %>%
    str_squish()
}

posts <- posts %>% mutate(text_clean = clean_text(text_raw))
if (nrow(posts) == 0) stop("There are no nonblank posts to analyze.")

cleaning_audit <- tibble(
  measure = c("Original rows", "Blank text rows removed",
              "Duplicate post IDs removed", "Posts retained",
              "Distinct authors retained", "Distinct exact texts retained",
              "Extra repeated texts across separate posts",
              "Posts with no text after URL/mention cleaning"),
  value = c(nrow(raw_posts), nrow(raw_posts) - nrow(nonblank_posts),
            nrow(nonblank_posts) - nrow(posts), nrow(posts),
            n_distinct(posts$author_handle, na.rm = TRUE),
            n_distinct(posts$text_raw),
            nrow(posts) - n_distinct(posts$text_raw),
            sum(posts$text_clean == ""))
)
knitr::kable(cleaning_audit, col.names = c("Check", "Count"))
Check Count
Original rows 100
Blank text rows removed 3
Duplicate post IDs removed 0
Posts retained 97
Distinct authors retained 56
Distinct exact texts retained 93
Extra repeated texts across separate posts 4
Posts with no text after URL/mention cleaning 1

The cleaning removes blank original texts and repeated post IDs. URLs, mentions, and escaped line breaks are removed from a separate text column, while original text is preserved for review. Separate posts with repeated wording remain in the main analysis because they have different post IDs. A later sensitivity check uses one copy of each exact text. Posts that become empty after cleaning remain in the post denominator and receive no sentiment matches.

Verify the cleaning

These checks compare the supplied file with independently counted values. The reconciliation and uniqueness checks should always pass; the snapshot checks specifically describe this uploaded CSV.

stopifnot(
  nrow(raw_posts) == (nrow(raw_posts) - nrow(nonblank_posts)) +
    (nrow(nonblank_posts) - nrow(posts)) + nrow(posts),
  anyDuplicated(posts$post_key) == 0L,
  all(str_squish(posts$text_raw) != ""),
  !any(str_detect(posts$text_clean, regex("https?://|www\\.",
                                        ignore_case = TRUE)))
)

snapshot_checks <- tibble(
  check = c("Original rows", "Blank original texts", "Retained posts",
            "Retained authors", "Distinct exact texts"),
  expected = c(100L, 3L, 97L, 56L, 93L),
  observed = c(nrow(raw_posts), nrow(raw_posts) - nrow(nonblank_posts),
               nrow(posts), n_distinct(posts$author_handle, na.rm = TRUE),
               n_distinct(posts$text_raw))
) %>% mutate(passed = expected == observed)
knitr::kable(snapshot_checks)
check expected observed passed
Original rows 100 100 TRUE
Blank original texts 3 3 TRUE
Retained posts 97 97 TRUE
Retained authors 56 56 TRUE
Distinct exact texts 93 93 TRUE
if (!all(snapshot_checks$passed)) {
  warning("The imported file differs from the original snapshot. Review the audit.")
}

2. Text analysis

Tokenization makes one row per word occurrence and converts words to lowercase. Tokens must contain a letter, contain no numbers, and have at least two characters. Unicode letters are preserved. Hashtag words remain available after punctuation is removed. English stop words and the search term nike are excluded only from the word-frequency display, so other topics are easier to see.

all_tokens <- posts %>%
  dplyr::select(post_id, text_clean) %>%
  unnest_tokens(word, text_clean) %>%
  filter(str_detect(word, "\\p{L}"),
         !str_detect(word, "\\p{N}"),
         str_length(word) >= 2)

frequency_tokens <- all_tokens %>%
  anti_join(tidytext::stop_words, by = "word") %>%
  filter(word != "nike")

word_counts <- frequency_tokens %>%
  count(word, sort = TRUE, name = "occurrences") %>%
  arrange(desc(occurrences), word)
top_words <- word_counts %>% slice_head(n = 15)
knitr::kable(top_words, col.names = c("Word", "Occurrences"))
Word Occurrences
ad 24
de 23
air 20
cupom 20
tênis 19
por 18
chez 15
sneakers 14
le 11
masculino 11
mercado 11
livre 10
pour 10
size 9
check 8
ggplot(top_words, aes(x = reorder(word, occurrences), y = occurrences)) +
  geom_col(fill = "#286DA8") +
  coord_flip() +
  labs(title = "Most common words beyond the search term Nike",
       subtitle = "English stop words removed; repeated occurrences counted",
       x = NULL, y = "Word occurrences") +
  theme_minimal(base_size = 12)

context_counts <- tibble(
  measure = c("Retained posts", "Posts containing standalone Nike",
              "Posts containing #ad", "Posts containing HTTP(S) links",
              "Word occurrences before stop-word removal"),
  count = c(nrow(posts),
            sum(str_detect(posts$text_raw, regex("\\bnike\\b", ignore_case = TRUE))),
            sum(str_detect(posts$text_raw, regex("#ad\\b", ignore_case = TRUE))),
            sum(str_detect(posts$text_raw, regex("https?://", ignore_case = TRUE))),
            nrow(all_tokens))
)
knitr::kable(context_counts)
measure count
Retained posts 97
Posts containing standalone Nike 90
Posts containing #ad 23
Posts containing HTTP(S) links 43
Word occurrences before stop-word removal 1802

Frequent words describe what appears in the sample, not whether people like the brand. The #ad count is a narrow indicator of advertising and does not identify every promotional post. English stop words do not remove common words in other languages, so multilingual content also affects the frequency results.

3. Sentiment analysis

Sentiment uses all_tokens, before English stop-word removal or removal of the word Nike. Each occurrence matching the Bing dictionary contributes either +1 or -1. A post score equals its positive matches minus its negative matches. This method does not adjust for negation, sarcasm, emoji, language, or the target of an opinion.

bing <- tidytext::get_sentiments("bing")
sentiment_tokens <- all_tokens %>%
  inner_join(bing, by = "word")

post_matches <- sentiment_tokens %>%
  group_by(post_id) %>%
  summarise(positive = sum(sentiment == "positive"),
            negative = sum(sentiment == "negative"), .groups = "drop")

category_levels <- c("Positive score", "Negative score",
                     "Balanced matches", "No sentiment matches")

post_sentiment <- posts %>%
  left_join(post_matches, by = "post_id") %>%
  mutate(positive = coalesce(positive, 0L),
         negative = coalesce(negative, 0L),
         matched_words = positive + negative,
         score = positive - negative,
         category = case_when(
           matched_words == 0 ~ "No sentiment matches",
           score > 0 ~ "Positive score",
           score < 0 ~ "Negative score",
           TRUE ~ "Balanced matches"
         ),
         category = factor(category, levels = category_levels))

sentiment_summary <- post_sentiment %>%
  count(category, name = "posts", .drop = FALSE) %>%
  mutate(percent = round(100 * posts / sum(posts), 1))
knitr::kable(sentiment_summary,
             col.names = c("Dictionary result", "Posts", "Percent of retained posts"))
Dictionary result Posts Percent of retained posts
Positive score 31 32.0
Negative score 6 6.2
Balanced matches 1 1.0
No sentiment matches 59 60.8
matched_posts <- sum(post_sentiment$matched_words > 0)
coverage_percent <- round(100 * matched_posts / nrow(posts), 1)
token_coverage_percent <- if (nrow(all_tokens) > 0) {
  round(100 * nrow(sentiment_tokens) / nrow(all_tokens), 1)
} else 0

The dictionary matched at least one word in 38 of 97 posts (39.2%). It matched 54 of 1802 eligible word occurrences (3%). These are coverage measures, not accuracy measures. No sentiment matches does not mean neutral. Balanced matches means the dictionary found equal nonzero positive and negative counts; it also does not prove neutrality.

Interactive Plotly chart

Hover over a bar to see the post count and percentage. The categories summarize dictionary scores, not verified opinions about Nike.

sentiment_chart <- plotly::plot_ly(
  data = sentiment_summary,
  x = ~category, y = ~posts,
  type = "bar",
  text = ~paste0(as.character(category), "<br>Posts: ", posts,
                 "<br>Share of retained posts: ", percent, "%"),
  hoverinfo = "text",
  marker = list(color = c("#27826B", "#B54B50", "#B18B36", "#7A8491"))
) %>%
  plotly::layout(
    title = list(text = "Bing dictionary scores across retained BlueSky posts"),
    xaxis = list(title = "", tickangle = -18, automargin = TRUE),
    yaxis = list(title = "Number of posts", rangemode = "tozero", dtick = 10),
    margin = list(b = 105), showlegend = FALSE
  ) %>%
  plotly::config(displaylogo = FALSE, responsive = TRUE)
sentiment_chart

Words contributing to the scores

sentiment_word_counts <- sentiment_tokens %>%
  count(sentiment, word, sort = TRUE, name = "occurrences") %>%
  group_by(sentiment) %>%
  slice_max(occurrences, n = 8, with_ties = FALSE) %>%
  ungroup() %>%
  arrange(sentiment, desc(occurrences), word)
knitr::kable(sentiment_word_counts)
sentiment word occurrences
negative bitch 1
negative boycott 1
negative defy 1
negative evil 1
negative freak 1
negative hurting 1
negative leak 1
negative prejudice 1
positive available 9
positive uplift 7
positive elite 2
positive nice 2
positive premier 2
positive well 2
positive appreciate 1
positive convenience 1

4. Verify the results and inspect context

The following checks verify that every retained post has exactly one category, word matches reconcile with the post scores, and the calculation gives the expected answer for a small hand-check example.

stopifnot(
  nrow(post_sentiment) == nrow(posts),
  anyDuplicated(post_sentiment$post_id) == 0L,
  sum(sentiment_summary$posts) == nrow(posts),
  sum(post_sentiment$positive) == sum(sentiment_tokens$sentiment == "positive"),
  sum(post_sentiment$negative) == sum(sentiment_tokens$sentiment == "negative"),
  all(post_sentiment$score == post_sentiment$positive - post_sentiment$negative),
  !anyNA(post_sentiment$category)
)

# Hand calculation: good (+1) + great (+1) + bad (-1) = +1.
toy_tokens <- tibble(text = "good great bad") %>% unnest_tokens(word, text)
toy_matches <- toy_tokens %>% inner_join(bing, by = "word")
toy_positive <- sum(toy_matches$sentiment == "positive")
toy_negative <- sum(toy_matches$sentiment == "negative")
stopifnot(toy_positive == 2L, toy_negative == 1L,
          toy_positive - toy_negative == 1L)
knitr::kable(tibble(example = "good great bad", positive = toy_positive,
                    negative = toy_negative,
                    expected_score = 1L,
                    calculated_score = toy_positive - toy_negative))
example positive negative expected_score calculated_score
good great bad 2 1 1 1

Spot checks of real posts

The row numbers below refer to the original input order. These short excerpts illustrate context that a word dictionary can miss. The matched-word column makes the calculation inspectable without publishing author handles.

review_notes <- tibble(
  post_id = c(10L, 28L, 30L, 87L, 92L, 95L, 98L),
  excerpt = c('Nike SB Air Force 1 "Cool Grey"',
              "BOYCOTT WILDWOOD!",
              "remains of a Nike missile battery",
              "grossed out ... really nice responses",
              "Nike Missile Silo",
              "Nike knocked 114% off",
              "Good Times es un temón"),
  human_review = c(
    "Cool Grey names a color. A positive word match need not express satisfaction.",
    "Exaggerated wording may be sarcastic. The intended message requires context.",
    "Nike refers to a missile site rather than the footwear brand.",
    "Negative feelings concern advertising; positive words concern councilors' responses.",
    "This concerns a missile site. The dictionary also ignores the sad emoji.",
    "The claimed 114% discount is implausible and requires a content check.",
    "An English song title appears inside Spanish music commentary."
  )
)

matched_details <- sentiment_tokens %>%
  filter(post_id %in% review_notes$post_id) %>%
  group_by(post_id) %>%
  summarise(matched_terms = paste0(word, " (", sentiment, ")", collapse = "; "),
            .groups = "drop")

review_table <- review_notes %>%
  left_join(post_sentiment %>%
              dplyr::select(post_id, positive, negative, score, category),
            by = "post_id") %>%
  left_join(matched_details, by = "post_id") %>%
  mutate(matched_terms = coalesce(matched_terms, "None"))
knitr::kable(review_table)
post_id excerpt human_review positive negative score category matched_terms
10 Nike SB Air Force 1 “Cool Grey” Cool Grey names a color. A positive word match need not express satisfaction. 1 0 1 Positive score cool (positive)
28 BOYCOTT WILDWOOD! Exaggerated wording may be sarcastic. The intended message requires context. 3 2 1 Positive score support (positive); enjoy (positive); works (positive); evil (negative); boycott (negative)
30 remains of a Nike missile battery Nike refers to a missile site rather than the footwear brand. 1 0 1 Positive score like (positive)
87 grossed out … really nice responses Negative feelings concern advertising; positive words concern councilors’ responses. 2 0 2 Positive score recommend (positive); nice (positive)
92 Nike Missile Silo This concerns a missile site. The dictionary also ignores the sad emoji. 1 0 1 Positive score golden (positive)
95 Nike knocked 114% off The claimed 114% discount is implausible and requires a content check. 0 0 0 No sentiment matches None
98 Good Times es un temón An English song title appears inside Spanish music commentary. 2 0 2 Positive score good (positive); led (positive)

These examples check meaning as well as arithmetic. For example, a positive score for a color name or for a response from a councilor would not establish a positive opinion about Nike. The examples are illustrative, not a random validation set, so no classification accuracy percentage is claimed.

Sensitivity to repeated text

unique_text_sentiment <- post_sentiment %>% distinct(text_raw, .keep_all = TRUE)
unique_text_summary <- unique_text_sentiment %>%
  count(category, name = "unique_texts", .drop = FALSE) %>%
  mutate(unique_text_percent = round(100 * unique_texts / sum(unique_texts), 1))

sensitivity <- sentiment_summary %>%
  rename(all_posts = posts, all_post_percent = percent) %>%
  left_join(unique_text_summary, by = "category")
knitr::kable(sensitivity)
category all_posts all_post_percent unique_texts unique_text_percent
Positive score 31 32.0 30 32.3
Negative score 6 6.2 6 6.5
Balanced matches 1 1.0 1 1.1
No sentiment matches 59 60.8 56 60.2

This compares all 97 posts with 93 exact distinct texts. It shows whether repeated wording changes the category shares. Near-duplicates, advertisements without #ad, and repeated authors can still influence the results.

5. Findings and limitations

The file contains 100 rows. Removing 3 blank texts and 0 repeated post IDs leaves 97 posts from 56 authors.

After English stop words and the query term Nike are excluded, the leading word counts are ad (24), de (23), air (20), cupom (20), tênis (19). These counts describe the sample’s wording.

The dictionary results are Positive score: 31 (32%); Negative score: 6 (6.2%); Balanced matches: 1 (1%); No sentiment matches: 59 (60.8%).

The safest conclusion is that this sample contains a mixture of product discussion, promotions, and unrelated meanings of Nike. English, Portuguese, French, Dutch, and Spanish text appears in the supplied data, and the English dictionary does not treat those languages equally. The sample is small, includes repeated wording, and was not provided with evidence of random sampling. Post scores also ignore sentence meaning, negation, emoji, and who or what a sentiment is about. These results should not be described as proof that customers generally like or dislike Nike.

A stronger follow-up would manually review brand relevance, language, and promotional content before comparing sentiment within a clearly defined subset. A human-labeled sample would be needed to evaluate how accurately a method identifies opinions about the brand.

6. AI prompt record

Original prompt received

Do this.

The request included the assignment screenshots and the BlueSky CSV. The AI response was this R Markdown draft, including the cleaning audit, frequency analysis, sentiment scoring, Plotly chart, verification code, and discussion of limitations. It also identified the Console error: YAML such as --- and title: belongs in the R Markdown editor and is processed by Knit, rather than executed as R commands in the Console.

Improved follow-up prompt to send

Review the Lab 13.2 R Markdown file you created using my BlueSky CSV. Check that cleaning leaves 97 posts from 100 rows, that the sentiment totals include all retained posts, and that posts with no matches are not labeled neutral. Explain how multilingual posts, advertisements, sarcasm, and Nike missile-site posts could affect the results. Fix any problems you find and help me interpret the Plotly chart in simple language.

This follow-up is a suggested prompt, not a second request already made. The assignment requires asking AI at least twice. Send this prompt (or your own improved version), review the response, and update this section with what was actually asked and received. Save real screenshots of both prompts and responses for the discussion forum. Do not present the suggested prompt as an interaction that has already happened.

References

Reproducibility

The session information below records the R and package versions used when this file is knitted. The report uses inline calculations so its numerical findings update from the imported data.

## R version 4.6.2 (2026-10-29)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.5 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
##  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
##  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
## [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
## 
## time zone: UTC
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] plotly_4.12.1  ggplot2_4.0.4  tidytext_0.4.3 stringr_1.6.0  tidyr_1.3.2   
## [6] dplyr_1.2.1    readr_2.2.0   
## 
## loaded via a namespace (and not attached):
##  [1] janeaustenr_1.0.0   sass_0.4.10         generics_0.1.4     
##  [4] stringi_1.8.9       lattice_0.23-1      hms_1.1.4          
##  [7] digest_0.6.39       magrittr_2.0.5      evaluate_1.0.5     
## [10] grid_4.6.2          RColorBrewer_1.1-3  fastmap_1.2.0      
## [13] jsonlite_2.0.0      Matrix_1.7-6        httr_1.4.9         
## [16] purrr_1.2.2         crosstalk_1.2.2     viridisLite_0.4.3  
## [19] scales_1.4.0        jquerylib_0.1.4     cli_3.6.6          
## [22] crayon_1.5.3        rlang_1.3.0         tokenizers_0.3.0   
## [25] bit64_4.8.6         withr_3.0.3         cachem_1.1.0       
## [28] yaml_2.3.12         otel_0.3.0          parallel_4.6.2     
## [31] tools_4.6.2         tzdb_0.5.0          vctrs_0.7.3        
## [34] R6_2.6.1            lifecycle_1.0.5     bit_4.6.0          
## [37] htmlwidgets_1.6.4   vroom_1.7.1         pkgconfig_2.0.3    
## [40] pillar_1.11.1       bslib_0.12.0        gtable_0.3.6       
## [43] glue_1.8.1          data.table_1.18.6.1 Rcpp_1.1.2         
## [46] xfun_0.62           tibble_3.3.1        tidyselect_1.2.1   
## [49] knitr_1.52          farver_2.1.2        htmltools_0.5.9    
## [52] SnowballC_0.7.1     labeling_0.4.3      rmarkdown_2.32     
## [55] compiler_4.6.2      S7_0.2.2