Reflection

What the AI did well, and where it fell short. I used Claude to write this R Markdown file. My prompts started vague (“make it detailed and where the graphs look the best”), and the AI’s most useful habit was checking the data before analyzing it. When I first attached a numeric customer survey, it pointed out that the lab needs BlueSky text and asked what to analyze. When I attached our group’s scrapes, it found that two files didn’t contain what their names said (one was BMW M3 posts, one was governor-race posts). After I gave it two real movie scrapes, it produced a complete analysis quickly, with consistent interactive charts and built-in checks. But it could not run R in its own workspace, so it never saw its own output. Knitting the file, reading every table and chart, and fixing anything that broke was my job. My last prompt was specific (packages, data frame, chart and a required check), and it got a focused answer.

What human judgment still contributes. Most of the important decisions here were judgment calls, not code. Gian’s file was saved in a Windows encoding that garbles apostrophes, and Excel had already turned emojis into “??”. Searching for “movies” also pulled in adult-content promo accounts, because “movies” appears in their links; a simple keyword filter would also have removed a real opinion post, so I filtered on promo hashtags and account names instead. I capped repeat accounts (on Nov 19 a news aggregator posted 13 times and a music promoter 12 times), set aside posts in other languages, and noticed that the Bing lexicon scores genre words like “horror” and filler like “like” as opinions, so I removed them and showed the results both ways. The lexicon also misses sarcasm and negation (“not good” counts as positive), and topic keywords like “bond” or “disney” can catch the wrong posts, so I read examples myself. Both files cover only a few hours each, so these are snapshots of two days, not trends. Deciding what the results mean for a business, such as which movie conversations a theater should join, is still a human call. [Add 1–2 sentences with your thoughts on this new lab.]

Prompt log

Prompt 1 (original). Attached customer_segmentation.csv, pasted the full Lab 13.2 instructions, and wrote: “i want you to work on this and make it detailed and where the graphs look the best and can you make it in rmarkdown”

AI response (summary). The AI flagged that the survey file has no text for sentiment analysis and asked whether to analyze the survey, our BlueSky data, or both. I chose both, and it wrote a first draft. It said it could not knit the file because R is not installed in its workspace.

Why it was weak. No packages, no definition of a “good” graph, no BlueSky data, and no request for verification.

Prompt 2. Attached three BlueSky files and wrote: “i need it for these can you do it for these”

AI response (summary). Before analyzing, the AI checked the files and found that movies_bluesky_posts.csv held BMW M3 posts and Victor_Week11_MatineeSales.csv held California governor-race posts, and that Gian’s file used Windows encoding. It rebuilt the analysis around all three and labeled each file by its real contents.

Prompt 3. Attached movies_bluesky_posts_2026-11-19.csv and Gian_Abundo_-Scrape_Movies_11-3Sheet1.csv and wrote: “can you re do it but with these data nothing else”

AI response (summary). The AI removed the survey and the off-topic files and rebuilt the report around the two movie scrapes as a Nov 3 vs. Nov 19 comparison. It added a filter for adult-content promo posts, word and topic comparisons between the days, sentiment by day and by topic, and five verification checks.

Why Prompts 2–3 were still weak. They didn’t say what the files contained, what questions to answer, or what output I needed.

Prompt 4 (improved). “In my Lab 13.2 R Markdown, add one plotly chart that compares average likes for Positive, Neutral and Negative posts on Nov 3 vs. Nov 19. Use only tidyverse and plotly, reuse my style_plotly() function and day colors, and use the existing post_scores data frame (keep the 5-posts-per-account cap). Under the chart, add a check that recomputes the Nov 19 averages with base R aggregate() and shows both results side by side. Don’t change any other section.”

AI response (summary). [Summarize what the AI changed after this prompt.]

1 Setup

# Install once in the Console if any are missing (do NOT leave install.packages() in a knitted file):
# install.packages(c("tidyverse", "plotly", "tidytext", "knitr", "kableExtra"))
library(tidyverse)   # dplyr, tidyr, readr, stringr, forcats, lubridate
library(plotly)      # interactive charts
library(tidytext)    # tokenizing + Bing sentiment lexicon (ships inside the package)
library(knitr)       # tables
library(kableExtra)  # table styling
# One palette for the whole report (checked for color-blind safety)
pal <- list(
  surface = "#fcfcfb", ink = "#0b0b0b", ink2 = "#52514e", muted = "#898781",
  grid = "#e1e0d9", axis = "#c3c2b7",
  blue = "#2a78d6", red = "#e34948", violet = "#6250d6", aqua = "#1baf7a"
)

# Shared look for every plotly chart
style_plotly <- function(p, title, subtitle = NULL, xlab = "", ylab = "", legend = TRUE) {
  ttl <- paste0("<b>", title, "</b>")
  sub_lines <- 0
  if (!is.null(subtitle)) {
    wrapped   <- strwrap(subtitle, width = 95)   # plotly titles don't wrap on their own
    sub_lines <- length(wrapped)
    ttl <- paste0(ttl, "<br>",
                  paste0("<span style='font-size:13px;color:", pal$ink2, "'>", wrapped, "</span>",
                         collapse = "<br>"))
  }
  top_margin <- 25 + 23 * (1 + sub_lines) + if (legend) 32 else 0
  ax <- function(lab) list(
    title = list(text = lab, font = list(color = pal$ink2, size = 13)),
    gridcolor = pal$grid, linecolor = pal$axis, zerolinecolor = pal$axis,
    tickfont = list(color = pal$ink2, size = 12), automargin = TRUE
  )
  p %>%
    layout(
      title = list(text = ttl, x = 0.01, xref = "container", xanchor = "left",
                   y = 0.97, yref = "container", yanchor = "top",
                   font = list(size = 17, color = pal$ink)),
      font = list(family = "system-ui, -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif",
                  color = pal$ink2),
      paper_bgcolor = pal$surface, plot_bgcolor = pal$surface,
      xaxis = ax(xlab), yaxis = ax(ylab),
      showlegend = legend,
      legend = list(orientation = "h", x = 0, xanchor = "left", y = 1.02, yanchor = "bottom",
                    font = list(size = 12, color = pal$ink2)),
      margin = list(t = top_margin, r = 30, b = 60, l = 10),
      hoverlabel = list(bgcolor = "#ffffff", bordercolor = pal$grid,
                        font = list(color = pal$ink, size = 13))
    ) %>%
    config(displaylogo = FALSE,
           modeBarButtonsToRemove = c("lasso2d", "select2d", "autoScale2d", "toggleSpikelines"))
}

2 The data

Two BlueSky scrapes of posts that mention “movies”. Put both files in the same folder as this .Rmd.

bsky_files <- tribble(
  ~dataset, ~file,                                       ~encoding,      ~contents,
  "Nov 3",  "Gian_Abundo_-Scrape_Movies_11-3Sheet1.csv", "windows-1252", "Posts mentioning movies on Election Day, which was also Godzilla Day",
  "Nov 19", "movies_bluesky_posts_2026-11-19.csv",       "UTF-8",        "Posts mentioning movies on GTA 6 launch day, amid new James Bond casting news"
) %>%
  mutate(found = file.exists(file))

day_cols <- c("Nov 3" = pal$violet, "Nov 19" = pal$aqua)   # same color for each day in every chart

# The search term (and close synonyms) appear in nearly every post, so they would top every word chart
custom_stop <- c("movies", "movie", "film", "films", "amp", "https", "http", "www", "com",
                 "bsky", "app", "social")

# Adult-content promo posts matched "movies" only because the word is in their links.
# A plain keyword list also caught a real opinion post, so match promo tags and account names instead.
adult_text_pattern   <- "nsfw|onlyfans|hentai|\\bjav\\b|ecchi|aebn"
adult_author_pattern <- "porn"

# Keep at most this many posts per account in each file
max_posts_per_author <- 5

# Common English words used to spot posts written in other languages
en_function_words <- c("the", "and", "to", "of", "it", "you", "my", "this", "that", "for", "with",
                       "but", "not", "have", "just", "what", "we", "they", "be", "at", "or", "if",
                       "your", "are", "i'm", "don't", "it's", "about", "from", "had", "would", "can",
                       "all", "one", "out", "more", "when", "there", "their", "been", "who", "get")

# Words the Bing lexicon may score that are usually NOT opinions in movie posts:
# genre and plot words (a "horror" fan isn't being negative), names, and filler.
# Check 2 in the Verify section shows which ones actually matched, and the results both ways.
domain_words <- c("horror", "scary", "creepy", "monster", "monsters", "villain", "villains", "evil",
                  "dead", "death", "kill", "killer", "killing", "kills", "murder", "murders", "bloody",
                  "haunt", "haunts", "haunted", "nightmare", "nightmares", "terrified", "zombie",
                  "trump", "die", "like")
sentiment_ignore <- domain_words   # judgment call

bsky_ok <- any(bsky_files$found)

Missing file(s): Gian_Abundo_-Scrape_Movies_11-3Sheet1.csv. Put them next to this .Rmd and knit again.

2.1 Load the files

read_bsky <- function(file, encoding) {
  read_csv(file, locale = locale(encoding = encoding), show_col_types = FALSE,
           col_types = cols(.default = col_character()))
}

pick_col <- function(df, candidates) {
  hit <- intersect(candidates, names(df))
  if (length(hit) == 0) NA_character_ else hit[1]
}

parse_dt <- function(x) suppressWarnings(lubridate::ymd_hms(as.character(x), quiet = TRUE))

# Put both files into the same columns (the two scrapers named them differently)
standardize <- function(df, dataset) {
  text_col   <- pick_col(df, c("text", "post_text", "content"))
  date_col   <- pick_col(df, c("indexed_at", "created_at", "date"))
  author_col <- pick_col(df, c("author_handle", "handle", "author"))
  like_col   <- pick_col(df, c("like_count", "likes"))
  if (is.na(text_col)) stop("No post-text column found in the ", dataset, " file.")
  tibble(
    dataset  = dataset,
    author   = if (!is.na(author_col)) df[[author_col]] else NA_character_,
    created  = if (!is.na(date_col)) parse_dt(df[[date_col]]) else as.POSIXct(NA),
    likes    = if (!is.na(like_col)) suppressWarnings(as.numeric(df[[like_col]])) else NA_real_,
    text_raw = df[[text_col]]
  )
}

files_found <- bsky_files %>% filter(found)
raw_list    <- map2(files_found$file, files_found$encoding, read_bsky)
posts_all   <- bind_rows(map2(raw_list, files_found$dataset, standardize))
ds_list     <- files_found$dataset   # dataset order used in every chart

encoding_guess <- map_chr(files_found$file, function(f) {
  g <- guess_encoding(f)
  if (nrow(g) == 0) NA_character_ else paste0(g$encoding[1], " (", round(g$confidence[1], 2), ")")
})

posts_all %>%
  group_by(dataset) %>%
  summarise(Rows = n(),
            `First post` = format(min(created, na.rm = TRUE), "%b %d %H:%M"),
            `Last post`  = format(max(created, na.rm = TRUE), "%b %d %H:%M"),
            `Missing times` = sum(is.na(created)), .groups = "drop") %>%
  right_join(files_found %>% mutate(`Encoding guess` = encoding_guess), by = "dataset") %>%
  transmute(Dataset = dataset, File = file, `What's inside` = contents, Rows,
            `First post`, `Last post`, `Missing times`, `Encoding guess`, `Encoding used` = encoding) %>%
  kbl(caption = "The two files (times as stored in each file)") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = TRUE)
The two files (times as stored in each file)
Dataset File What’s inside Rows First post Last post Missing times Encoding guess Encoding used
Nov 19 movies_bluesky_posts_2026-11-19.csv Posts mentioning movies on GTA 6 launch day, amid new James Bond casting news 596 Nov 19 19:55 Nov 19 23:14 0 UTF-8 (1) UTF-8

Data problems caught before any analysis. (1) Gian’s file was saved from Excel in Windows encoding. Read as UTF-8, every curly apostrophe and accented letter turns into �, so it is read with windows-1252. Excel had already replaced emojis with ??, which can’t be undone. (2) Some posts are empty: link-only posts from news-site bridge accounts arrive with no text. (3) A search for “movies” also matches posts whose links contain “/movies/”, including adult-content promo accounts. (4) Each file covers only a few hours, so these are snapshots of two days, not trends.

2.2 Clean the text

clean_text <- function(x) {
  x %>%
    str_replace_all("https?://\\S+", " ") %>%            # links
    str_replace_all("@[A-Za-z0-9._-]+", " ") %>%         # @handles
    str_replace_all("&amp;", "&") %>%
    str_replace_all("[‘’]", "'") %>%           # curly -> straight apostrophes
    str_replace_all("#", " ") %>%                         # keep hashtag words, drop the #
    str_replace_all("[^[:alnum:][:space:]']", " ") %>%   # emojis, punctuation, the ?? Excel left
    str_squish() %>%
    str_to_lower()
}

posts_clean <- posts_all %>%
  filter(!is.na(text_raw)) %>%
  mutate(text_clean = clean_text(text_raw)) %>%
  filter(text_clean != "")                                       # posts that were only a link or emojis

posts_dedup <- posts_clean %>%
  distinct(dataset, text_clean, .keep_all = TRUE)                # same text posted twice

posts_safe <- posts_dedup %>%
  mutate(adult_promo = str_detect(str_to_lower(text_raw), adult_text_pattern) |
                       str_detect(str_to_lower(coalesce(author, "")), adult_author_pattern)) %>%
  filter(!adult_promo)

posts_capped <- posts_safe %>%
  mutate(author_key = coalesce(author, paste0("unknown_", row_number()))) %>%
  group_by(dataset, author_key) %>%
  slice_head(n = max_posts_per_author) %>%
  ungroup()

# Language check: count common English words in each post
lang_check <- posts_capped %>%
  mutate(row = row_number()) %>%
  select(row, text_clean) %>%
  unnest_tokens(word, text_clean) %>%
  group_by(row) %>%
  summarise(n_tokens = n(), n_function = sum(word %in% en_function_words), .groups = "drop")

posts <- posts_capped %>%
  mutate(row = row_number()) %>%
  left_join(lang_check, by = "row") %>%
  mutate(n_tokens     = replace_na(n_tokens, 0L),
         n_function   = replace_na(n_function, 0L),
         english_like = n_function >= 1 | n_tokens <= 6)        # very short posts are kept

posts_en <- posts %>%                                            # the set that gets analyzed
  filter(english_like) %>%
  mutate(post_id = row_number())

step_levels <- c("Rows in file", "Has text after cleaning", "After removing duplicates",
                 "After removing adult-content promos",
                 paste0("After cap of ", max_posts_per_author, " posts per account"),
                 "Analyzed (has common English words, or 6 words or fewer)")

list(posts_all, posts_clean, posts_dedup, posts_safe, posts_capped, posts_en) %>%
  map2(step_levels, ~ count(.x, dataset, name = "posts") %>% mutate(Step = .y)) %>%
  bind_rows() %>%
  mutate(Step = factor(Step, levels = step_levels),
         dataset = factor(dataset, levels = ds_list)) %>%
  arrange(dataset) %>%
  pivot_wider(names_from = dataset, values_from = posts) %>%
  arrange(Step) %>%
  kbl(caption = "Posts left after each cleaning step") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = FALSE, position = "left")
Posts left after each cleaning step
Step Nov 19
Rows in file 596
Has text after cleaning 585
After removing duplicates 585
After removing adult-content promos 579
After cap of 5 posts per account 564
Analyzed (has common English words, or 6 words or fewer) 539
# Why the cap? The busiest accounts before it was applied
posts_safe %>%
  count(dataset, author, sort = TRUE) %>%
  group_by(dataset) %>%
  slice_head(n = 3) %>%
  ungroup() %>%
  rename(Dataset = dataset, Account = author, Posts = n) %>%
  kbl(caption = "Three busiest accounts per day (before the cap)") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = FALSE, position = "left")
Three busiest accounts per day (before the cap)
Dataset Account Posts
Nov 19 justpastemovies.bsky.social 13
Nov 19 jazzcomposer.bsky.social 12
Nov 19 mcbastard2000.bsky.social 4
# Which posts did the language check drop?
posts %>%
  filter(!english_like) %>%
  group_by(dataset) %>%
  slice_head(n = 3) %>%
  ungroup() %>%
  transmute(Dataset = dataset, `Dropped post` = str_trunc(str_squish(text_raw), 110)) %>%
  kbl(caption = "Examples removed by the language check") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = TRUE)
Examples removed by the language check
Dataset Dropped post
Nov 19 Anthropic’s Trillion-Dollar Leap: Washington Scrambles - azeem–usa.blogspot.com/2026/11/anth…
Nov 19 UN Court Rules Myanmar Committed Genocide Against Rohingya - azeem–usa.blogspot.com/2026/11/un-c…
Nov 19 #NowWatching Deathgasm II: Goremageddon (2026) #filmsky #horrorsky #movies

The language check also drops a few English posts that are bare listings with no common words (for example a product title). Those rarely contain sentiment words, so dropping them mostly changes the share of “neutral” posts.

3 Text analysis

3.1 Chart 1 — Most-used words each day

words <- posts_en %>%
  select(post_id, dataset, text_clean) %>%
  unnest_tokens(word, text_clean) %>%
  anti_join(stop_words, by = "word") %>%
  filter(!word %in% custom_stop,
         !str_detect(word, "^[0-9]+$"),
         nchar(word) > 1)

top_words <- words %>%
  count(dataset, word, sort = TRUE) %>%
  group_by(dataset) %>%
  slice_max(n, n = 12, with_ties = FALSE) %>%
  ungroup()

word_charts <- lapply(ds_list, function(ds) {
  d <- top_words %>% filter(dataset == ds) %>% mutate(word = fct_reorder(word, n))
  plot_ly(d, x = ~n, y = ~word, type = "bar", orientation = "h", height = 420,
          marker = list(color = day_cols[[ds]]),
          hovertemplate = "<b>%{y}</b><br>%{x} mentions<extra></extra>") %>%
    style_plotly(title = paste0(ds, ": most-used words"),
                 subtitle = paste0(sum(posts_en$dataset == ds),
                                   " posts. Stop words, links, handles, the search term and close synonyms removed."),
                 xlab = "Mentions", legend = FALSE) %>%
    layout(bargap = 0.3)
})
htmltools::tagList(word_charts)

3.2 Chart 2 — Words that set the two days apart

Raw counts favor the bigger file, so this compares each word’s share of all words that day.

day_a <- ds_list[1]
day_b <- ds_list[2]
tot_a <- sum(words$dataset == day_a)
tot_b <- sum(words$dataset == day_b)

distinct_words <- words %>%
  count(dataset, word) %>%
  pivot_wider(names_from = dataset, values_from = n, values_fill = 0) %>%
  rename(n_a = all_of(day_a), n_b = all_of(day_b)) %>%
  filter(n_a + n_b >= 4) %>%                                  # ignore rare words
  mutate(log_ratio = log2(((n_b + 1) / (tot_b + 1)) / ((n_a + 1) / (tot_a + 1))))   # +1 avoids dividing by 0

d <- bind_rows(slice_max(distinct_words, log_ratio, n = 10, with_ties = FALSE),
               slice_min(distinct_words, log_ratio, n = 10, with_ties = FALSE)) %>%
  mutate(side = if_else(log_ratio > 0, day_b, day_a),
         word = fct_reorder(word, log_ratio),
         hover = paste0("<b>", word, "</b><br>", day_a, ": ", n_a, " uses<br>", day_b, ": ", n_b, " uses"))

plot_ly(d, x = ~log_ratio, y = ~word, type = "bar", orientation = "h", height = 560,
        color = ~side, colors = day_cols, text = ~hover, hoverinfo = "text", textposition = "none") %>%
  style_plotly(title = paste0("What people talked about on ", day_a, " vs. ", day_b),
               subtitle = "Each bar = how much more common a word was on one day (log2 scale: 1 = twice as common, 2 = four times). Hover for counts.",
               xlab = paste0("← more typical of ", day_a, "      more typical of ", day_b, " →")) %>%
  layout(barmode = "relative", bargap = 0.3)
posts_en %>%
  select(post_id, dataset, text_clean) %>%
  unnest_tokens(bigram, text_clean, token = "ngrams", n = 2) %>%
  filter(!is.na(bigram)) %>%
  separate(bigram, into = c("w1", "w2"), sep = " ") %>%
  filter(!w1 %in% c(stop_words$word, custom_stop),
         !w2 %in% c(stop_words$word, custom_stop),
         !str_detect(w1, "^[0-9]+$"), !str_detect(w2, "^[0-9]+$")) %>%
  count(dataset, w1, w2, sort = TRUE) %>%
  group_by(dataset) %>%
  slice_max(n, n = 6, with_ties = FALSE) %>%
  ungroup() %>%
  mutate(dataset = factor(dataset, levels = ds_list)) %>%
  arrange(dataset, desc(n)) %>%
  unite(Phrase, w1, w2, sep = " ") %>%
  rename(Day = dataset, Mentions = n) %>%
  kbl(caption = "Top two-word phrases each day") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = FALSE, position = "left")
Top two-word phrases each day
Day Phrase Mentions
Nov 19 video games 10
Nov 19 james bond 8
Nov 19 link amazon 7
Nov 19 blu ray 6
Nov 19 hunger games 6
Nov 19 filmsky moviesky 5

3.3 Chart 3 — Topics in the movie conversation

I grouped posts into topics with keyword lists. A post can belong to more than one topic. Check 5 in the Verify section shows a sample post for each topic, so the keywords can be checked by hand.

topic_dict <- tribble(
  ~topic,                  ~pattern,
  "Godzilla",              "godzilla|kaiju",
  "James Bond",            "\\bbond\\b|007|pattinson|bezos",
  "Horror",                "horror|scary|slasher",
  "Christmas / holiday",   "christmas|hallmark|holiday|xmas",
  "Star Wars / Star Trek", "star wars|star trek|anakin|jedi",
  "Superheroes",           "marvel|\\bmcu\\b|avengers|batman|superman|x men|wolverine",
  "Video games / GTA",     "\\bgta\\b|grand theft auto|video game|gaming",
  "Streaming services",    "netflix|disney|streaming|\\bhbo\\b|prime video|tubi|hulu",
  "Election / politics",   "election|midterm|\\bvote\\b|voting|trump|maga|senate"
)

post_topics <- posts_en %>%
  select(post_id, dataset, text_clean) %>%
  crossing(topic_dict) %>%
  filter(str_detect(text_clean, pattern)) %>%
  select(post_id, dataset, topic)

topic_share <- crossing(dataset = ds_list, topic = topic_dict$topic) %>%
  left_join(count(post_topics, dataset, topic), by = c("dataset", "topic")) %>%
  mutate(n = replace_na(n, 0L)) %>%
  left_join(count(posts_en, dataset, name = "total"), by = "dataset") %>%
  mutate(pct = n / total)

topic_order <- topic_share %>%
  group_by(topic) %>%
  summarise(avg_pct = mean(pct), .groups = "drop") %>%
  arrange(avg_pct) %>%
  pull(topic)

p_topics <- plot_ly(height = 520)
for (ds in ds_list) {
  d <- topic_share %>% filter(dataset == ds)
  p_topics <- p_topics %>%
    add_trace(data = d, x = ~pct, y = ~topic, type = "bar", orientation = "h", name = ds,
              marker = list(color = day_cols[[ds]], line = list(color = pal$surface, width = 1)),
              text = ~paste0("<b>", topic, "</b><br>", ds, ": ", n, " of ", total,
                             " posts (", scales::percent(pct, accuracy = 1), ")"),
              hoverinfo = "text", textposition = "none")
}

p_topics %>%
  style_plotly(title = "Each day had its own movie conversation",
               subtitle = "Share of each day's posts that mention a topic. Hover for counts.",
               xlab = "Share of posts") %>%
  layout(barmode = "group", bargap = 0.25, bargroupgap = 0.05,
         xaxis = list(tickformat = ".0%", rangemode = "tozero"),
         yaxis = list(categoryorder = "array", categoryarray = topic_order))
topic_share %>%
  mutate(cell = paste0(n, " (", scales::percent(pct, accuracy = 1), ")")) %>%
  select(Topic = topic, dataset, cell) %>%
  pivot_wider(names_from = dataset, values_from = cell) %>%
  mutate(Topic = factor(Topic, levels = rev(topic_order))) %>%
  arrange(Topic) %>%
  kbl(caption = "Posts per topic (share of that day's posts)") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = FALSE, position = "left")
Posts per topic (share of that day’s posts)
Topic Nov 19
Streaming services 31 (6%)
James Bond 26 (5%)
Video games / GTA 25 (5%)
Superheroes 23 (4%)
Horror 23 (4%)
Christmas / holiday 21 (4%)
Election / politics 10 (2%)
Godzilla 6 (1%)
Star Wars / Star Trek 5 (1%)

4 Sentiment analysis (Bing lexicon)

The Bing lexicon labels about 6,800 English words as positive or negative. A post’s score = positive words − negative words. Words in sentiment_ignore are left out (see Check 2).

bing <- get_sentiments("bing") %>% distinct(word, .keep_all = TRUE)   # a few words are listed twice

tokens_all <- posts_en %>%
  select(post_id, dataset, text_clean) %>%
  unnest_tokens(word, text_clean) %>%
  filter(!word %in% custom_stop)

word_sent_raw <- tokens_all %>% inner_join(bing, by = "word")            # Bing exactly as published
word_sent     <- word_sent_raw %>% filter(!word %in% sentiment_ignore)  # after my review

score_posts <- function(ws) {
  ws %>%
    group_by(post_id) %>%
    summarise(positive = sum(sentiment == "positive"),
              negative = sum(sentiment == "negative"), .groups = "drop") %>%
    right_join(select(posts_en, post_id, dataset, author, created, likes, text_raw, text_clean),
               by = "post_id") %>%
    mutate(across(c(positive, negative), ~ replace_na(.x, 0L)),
           score = positive - negative,
           label = case_when(score > 0 ~ "Positive",
                             score < 0 ~ "Negative",
                             TRUE      ~ "Neutral / no lexicon words")) %>%
    arrange(post_id)
}

post_scores     <- score_posts(word_sent)
post_scores_raw <- score_posts(word_sent_raw)

post_scores %>%
  group_by(Day = dataset) %>%
  summarise(Posts = n(),
            avg = mean(score), se = sd(score) / sqrt(n()),
            Positive = scales::percent(mean(label == "Positive"), accuracy = 1),
            Neutral  = scales::percent(mean(label == "Neutral / no lexicon words"), accuracy = 1),
            Negative = scales::percent(mean(label == "Negative"), accuracy = 1), .groups = "drop") %>%
  mutate(`Avg score` = sprintf("%.2f", avg),
         `95% CI` = sprintf("%.2f to %.2f", avg - 1.96 * se, avg + 1.96 * se),
         Day = factor(Day, levels = ds_list)) %>%
  arrange(Day) %>%
  select(Day, Posts, `Avg score`, `95% CI`, Positive, Neutral, Negative) %>%
  kbl(caption = "Sentiment summary by day") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = FALSE, position = "left")
Sentiment summary by day
Day Posts Avg score 95% CI Positive Neutral Negative
Nov 19 539 0.33 0.20 to 0.46 38% 38% 24%

4.1 Chart 4 — Overall tone by day

sent_cols <- c("Negative" = pal$red, "Neutral / no lexicon words" = pal$muted, "Positive" = pal$blue)

share <- post_scores %>%
  count(dataset, label) %>%
  group_by(dataset) %>%
  mutate(total = sum(n), pct = n / total) %>%
  ungroup()

p_share <- plot_ly(height = 340)
for (lv in names(sent_cols)) {
  d <- share %>% filter(label == lv)
  if (nrow(d) == 0) next
  p_share <- p_share %>%
    add_trace(data = d, x = ~pct, y = ~dataset, type = "bar", orientation = "h", name = lv,
              marker = list(color = sent_cols[[lv]], line = list(color = pal$surface, width = 2)),
              text = ~if_else(pct >= 0.08, scales::percent(pct, accuracy = 1), ""),
              textposition = "inside", insidetextanchor = "middle",
              textfont = list(color = if (lv == "Neutral / no lexicon words") pal$ink else "#ffffff", size = 12),
              hovertext = ~paste0("<b>", dataset, "</b><br>", lv, ": ", n, " of ", total,
                                  " posts (", scales::percent(pct, accuracy = 1), ")"),
              hoverinfo = "text")
}

p_share %>%
  style_plotly(title = "How positive or negative were movie posts each day?",
               subtitle = "Share of posts by net Bing score (positive words minus negative words). Hover for counts.",
               xlab = "Share of posts") %>%
  layout(barmode = "stack", bargap = 0.45,
         xaxis = list(tickformat = ".0%", range = c(0, 1)),
         yaxis = list(categoryorder = "array", categoryarray = rev(ds_list)))

4.2 Chart 5 — Words driving the sentiment

sent_word_charts <- lapply(ds_list, function(ds) {
  d <- word_sent %>%
    filter(dataset == ds) %>%
    count(word, sentiment) %>%
    group_by(sentiment) %>%
    slice_max(n, n = 8, with_ties = FALSE) %>%
    ungroup() %>%
    mutate(sentiment = str_to_title(sentiment),
           n_signed  = if_else(sentiment == "Negative", -n, n),
           word      = fct_reorder(word, n_signed))
  m  <- max(abs(d$n_signed), 1)
  tv <- pretty(c(-m, m))
  plot_ly(d, x = ~n_signed, y = ~word, type = "bar", orientation = "h", height = 460,
          color = ~sentiment, colors = c("Negative" = pal$red, "Positive" = pal$blue),
          customdata = ~n,
          hovertemplate = "<b>%{y}</b><br>%{customdata} uses<extra>%{fullData.name}</extra>") %>%
    style_plotly(title = paste0(ds, ": top positive and negative words"),
                 subtitle = "Up to 8 words per side from the Bing lexicon, after removing genre words, names and filler.",
                 xlab = "Times used") %>%
    layout(barmode = "relative", bargap = 0.3,
           xaxis = list(tickvals = tv, ticktext = as.character(abs(tv))))
})
htmltools::tagList(sent_word_charts)

4.3 Chart 6 — Which topics had the most positive language?

topic_sent <- post_topics %>%
  left_join(select(post_scores, post_id, score), by = "post_id") %>%
  group_by(topic) %>%
  summarise(n = n(), mean = mean(score), se = sd(score) / sqrt(n()), .groups = "drop") %>%
  filter(n >= 5) %>%                                           # too few posts to say anything
  mutate(err = 1.96 * replace_na(se, 0)) %>%
  arrange(mean)

plot_ly(topic_sent, x = ~mean, y = ~topic, type = "scatter", mode = "markers", height = 480,
        error_x = ~list(type = "data", array = err, color = "#52514e", thickness = 1.5, width = 6),
        marker = list(color = pal$blue, size = 12, line = list(color = pal$surface, width = 2)),
        customdata = ~n,
        hovertemplate = "<b>%{y}</b><br>Average score: %{x:.2f}<br>%{customdata} posts<extra></extra>") %>%
  style_plotly(title = "Average sentiment by topic (both days combined)",
               subtitle = "Dot = average net score per post; whiskers = 95% confidence interval. Topics with fewer than 5 posts are left out.",
               xlab = "Average score (positive words − negative words)", legend = FALSE) %>%
  layout(yaxis = list(categoryorder = "array", categoryarray = topic_sent$topic),
         shapes = list(list(type = "line", yref = "paper", y0 = 0, y1 = 1, x0 = 0, x1 = 0,
                            line = list(color = pal$axis, width = 1.5, dash = "dot"))))

Reading it: Nov 19 posts averaged 0.33 (n = 539). The most-mentioned topic was Streaming services on Nov 19 (6%). Where confidence intervals overlap, the difference could easily be noise.

4.4 Most positive and most negative posts (read them!)

top_pos <- post_scores %>% group_by(dataset) %>% slice_max(score, n = 3, with_ties = FALSE) %>%
  ungroup() %>% mutate(Type = "Most positive")
top_neg <- post_scores %>% group_by(dataset) %>% slice_min(score, n = 3, with_ties = FALSE) %>%
  ungroup() %>% mutate(Type = "Most negative")

bind_rows(top_pos, top_neg) %>%
  mutate(dataset = factor(dataset, levels = ds_list)) %>%
  arrange(dataset, desc(Type), desc(abs(score))) %>%
  transmute(Day = dataset, Type, Score = score, Post = str_trunc(str_squish(text_raw), 170)) %>%
  kbl() %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = TRUE)
Day Type Score Post
Nov 19 Most positive 9 Looking for your next cozy read? These winter romance books capture the heartwarming love, festive charm, and feel-good magic of your favorite Hallmark movies.
Nov 19 Most positive 6 the exercise has not only led me to gorgeous, life-changing storytelling, but it also made me appreciate these simpler movies for children. And as an artist who cares …
Nov 19 Most positive 6 All of Brosnan’s pre-titles are great. His movies featured some of the most inventive action of the franchise. I want to say TWINE is best, but TND is so much fun and …
Nov 19 Most negative -4 I try not to be a villain, but I’m awfully fond of showing people weird embarrassing shit they probably aren’t glad to see. And if you tick me off, I’ll try to make yo…
Nov 19 Most negative -4 I was so shocked when I saw that preview. I’m never watching him in anything. Past or future. Not even if I get Flu A. I hope the movies lose money. I hope the studios…
Nov 19 Most negative -4 Nic Cage gets a pass from me, but it feels like overkill recently with Stallone, Madden and Stewart impression movies all dumped on us at once. It’s as if Hollywood sa…

5 Verify the code

Check 1 — re-score one post per day a different way. For each day I take the post with the most lexicon words and re-count it with plain base R (no tidytext).

pos_words <- bing$word[bing$sentiment == "positive"]
neg_words <- bing$word[bing$sentiment == "negative"]

bind_rows(lapply(ds_list, function(ds) {
  ps <- post_scores %>%
    filter(dataset == ds) %>%
    mutate(hits = positive + negative) %>%
    arrange(desc(hits), post_id) %>%
    slice(1)
  tk <- strsplit(ps$text_clean, "\\s+")[[1]]
  tk <- tk[!tk %in% c(custom_stop, sentiment_ignore)]
  tibble(Day = ds,
         Post = str_trunc(str_squish(ps$text_raw), 120),
         `Words found` = paste(word_sent$word[word_sent$post_id == ps$post_id], collapse = ", "),
         `tidytext score` = ps$score,
         `Base R score` = sum(tk %in% pos_words) - sum(tk %in% neg_words))
})) %>%
  mutate(Match = `tidytext score` == `Base R score`) %>%
  kbl() %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = TRUE)
Day Post Words found tidytext score Base R score Match
Nov 19 Looking for your next cozy read? These winter romance books capture the heartwarming love, festive charm, and feel-go… cozy, heartwarming, love, festive, charm, good, magic, favorite, hallmark 9 9 TRUE

Read each post: does the score match how a person would read it?

Check 2 — words that are not opinions in movie posts. These are the domain_words the Bing lexicon actually matched, and how much leaving them out changes the results.

word_sent_raw %>%
  filter(word %in% domain_words) %>%
  count(dataset, word, sentiment, sort = TRUE) %>%
  group_by(dataset) %>%
  slice_head(n = 6) %>%
  ungroup() %>%
  rename(Day = dataset, Word = word, `Bing calls it` = sentiment, Times = n) %>%
  kbl(caption = "Lexicon matches that are probably genre words, names or filler") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = FALSE, position = "left")
Lexicon matches that are probably genre words, names or filler
Day Word Bing calls it Times
Nov 19 like positive 72
Nov 19 trump positive 5
Nov 19 dead negative 4
Nov 19 death negative 4
Nov 19 villains negative 4
Nov 19 evil negative 3
summarise_scores <- function(ps, suffix) {
  ps %>%
    group_by(Day = dataset) %>%
    summarise(avg = round(mean(score), 2),
              pos = scales::percent(mean(label == "Positive"), accuracy = 1),
              neg = scales::percent(mean(label == "Negative"), accuracy = 1), .groups = "drop") %>%
    rename_with(~ paste0(.x, suffix), c(avg, pos, neg))
}

left_join(summarise_scores(post_scores_raw, " (Bing as-is)"),
          summarise_scores(post_scores, " (after review)"), by = "Day") %>%
  select(Day, starts_with("avg"), starts_with("pos"), starts_with("neg")) %>%
  kbl(caption = "Sensitivity check: results with and without the domain words") %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = TRUE)
Sensitivity check: results with and without the domain words
Day avg (Bing as-is) avg (after review) pos (Bing as-is) pos (after review) neg (Bing as-is) neg (after review)
Nov 19 0.42 0.33 42% 38% 22% 24%

Check 3 — negation. Bing scores words one at a time, so “not good” counts as positive. These sentiment words came right after a negating word:

negators <- c("not", "no", "never", "don't", "dont", "isn't", "can't", "won't", "without")

negated <- posts_en %>%
  select(post_id, dataset, text_clean) %>%
  unnest_tokens(bigram, text_clean, token = "ngrams", n = 2) %>%
  filter(!is.na(bigram)) %>%
  separate(bigram, into = c("w1", "w2"), sep = " ") %>%
  filter(w1 %in% negators, !w2 %in% sentiment_ignore) %>%
  inner_join(bing, by = c("w2" = "word")) %>%
  count(dataset, w1, w2, sentiment, sort = TRUE)

if (nrow(negated) == 0) {
  cat("No negated sentiment words found.\n")
} else {
  negated %>%
    head(12) %>%
    rename(Day = dataset, Negator = w1, Word = w2, `Scored as` = sentiment, Times = n) %>%
    kbl(caption = "Probably scored backwards") %>%
    kable_styling(bootstrap_options = c("striped", "condensed"), full_width = FALSE, position = "left")
}
Probably scored backwards
Day Negator Word Scored as Times
Nov 19 not enough positive 2
Nov 19 never loses negative 1
Nov 19 no good positive 1
Nov 19 no readily positive 1
Nov 19 no respectfully positive 1
Nov 19 not denounce negative 1
Nov 19 not easy positive 1
Nov 19 not excited positive 1
Nov 19 not right positive 1
Nov 19 without worrying negative 1
Nov 19 won’t bother negative 1

Check 4 — the adult-content filter. Counts only, so the removed posts are not reprinted here. The second column shows that a plain keyword search would also have flagged ordinary posts that merely mention a word like “porn”.

posts_dedup %>%
  mutate(flagged  = str_detect(str_to_lower(text_raw), adult_text_pattern) |
                    str_detect(str_to_lower(coalesce(author, "")), adult_author_pattern),
         naive    = str_detect(str_to_lower(paste(author, text_raw)), "porn|nsfw|onlyfans|hentai|\\bjav\\b|sex")) %>%
  group_by(Day = dataset) %>%
  summarise(`Removed by my filter` = sum(flagged),
            `Flagged by a plain keyword list` = sum(naive),
            `Caught only by the plain list (ordinary posts)` = sum(naive & !flagged), .groups = "drop") %>%
  kbl() %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = FALSE, position = "left")
Day Removed by my filter Flagged by a plain keyword list Caught only by the plain list (ordinary posts)
Nov 19 6 8 3

Check 5 — do the topic keywords catch the right posts? One random post per topic (set seed so it’s repeatable):

set.seed(4000)
post_topics %>%
  group_by(topic) %>%
  slice_sample(n = 1) %>%
  ungroup() %>%
  left_join(select(posts_en, post_id, text_raw), by = "post_id") %>%
  transmute(Topic = topic, Day = dataset, Post = str_trunc(str_squish(text_raw), 150)) %>%
  kbl() %>%
  kable_styling(bootstrap_options = c("striped", "condensed"), full_width = TRUE)
Topic Day Post
Christmas / holiday Nov 19 Four Christmas Horror Movies I’m looking forward to this year
Election / politics Nov 19 if your top horror movies look like high brow cinema selections we aren’t gonna get along
Godzilla Nov 19 On episode 252 of the #podcast the Movie Toasters talk about the latest #Popculture #News discuss some #Entertainment #Polls & #reviewed the follow…
Horror Nov 19 horror movies where people are trapped/stranded with a monster/monsters out and about are always my favorite horror films. and I wish we had more o…
James Bond Nov 19 I just had a discussion about bond movies with my wife and this is unironically me. Except the last one, I’ll take any kind of radical plastic surg…
Star Wars / Star Trek Nov 19 The Mandalorian chapters, The Book of Boba Fett, Ahsoka and the movies all live in one feed. I am working through them on the Star Wars Movie & TV …
Streaming services Nov 19 Wait seriously? Kids don’t know the basic morality stories and the old tropes any more? Do any of them realize the big Disney movies are based on f…
Superheroes Nov 19 me: (after tangentially mentioning professor x to wife) when we watch all the marvel movies you’ll understand what i mean wife: (deadpan) im not do…
Video games / GTA Nov 19 I’m here, sort of. Not playing GTA. Not really much of a gamer either since high school. I still do enjoy playing some semi-new titles though. Movi…

If a sample post isn’t really about its topic, tighten that topic’s pattern in topic_dict and knit again.

6 Critique of the AI output

What the AI did or assumed Why it matters What I (the human) did
My first file was a numeric survey; the lab needs BlueSky text The AI couldn’t know which the instructor wanted Chose the scope; this final version uses only BlueSky movie posts
Two earlier files didn’t match their names (BMW M3; governor race) Analyzing them as “movies” would mislabel everything Replaced them with two real movie scrapes
Gian’s file is saved in Windows-1252, not UTF-8 Apostrophes and accents become �; emojis were already lost as ?? Read it with the right encoding and stripped the ??
A search for “movies” matches link paths Adult-content promo posts would end up in a class report Filtered on promo hashtags and account names; a plain keyword list also hit real posts (Check 4)
A few accounts post over and over (13 and 12 posts on Nov 19) One account’s wording dominates word counts Capped each account at 5 posts per day
Some posts are in Japanese, Spanish, German and other languages Bing is English-only Set aside posts with no common English words
Bing scores genre words (“horror”), names and filler (“like”) as opinions Horror fans look negative; “like” looks positive Removed them from scoring and showed results both ways (Check 2)
Bing reads word by word Misses sarcasm, slang, emojis and negation (“not good” counts as positive) Ran a negation check and read the top and bottom posts
Topics come from keyword lists (“bond”, “disney”) Keywords can catch the wrong posts Printed a sample post per topic to check by hand (Check 5)
Each file covers only a few hours Two snapshots can’t show a trend Described results as snapshots of two days
AFINN/NRC lexicons need a download prompt That prompt makes knitting fail Used Bing, which ships inside tidytext
The AI could not run R in its workspace It never saw its own output I knitted the file, read every table and chart, and fixed errors
Session info (for reproducibility)
sessionInfo()
## 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] kableExtra_1.4.1 knitr_1.52       tidytext_0.4.3   plotly_4.12.1   
##  [5] lubridate_1.9.5  forcats_1.0.1    stringr_1.6.0    dplyr_1.2.1     
##  [9] purrr_1.2.2      readr_2.2.0      tidyr_1.3.2      tibble_3.3.1    
## [13] ggplot2_4.0.4    tidyverse_2.0.0 
## 
## loaded via a namespace (and not attached):
##  [1] janeaustenr_1.0.0   sass_0.4.10         generics_0.1.4     
##  [4] xml2_1.6.0          stringi_1.8.9       lattice_0.23-1     
##  [7] hms_1.1.4           digest_0.6.39       magrittr_2.0.5     
## [10] evaluate_1.0.5      grid_4.6.2          timechange_0.4.0   
## [13] RColorBrewer_1.1-3  fastmap_1.2.0       jsonlite_2.0.0     
## [16] Matrix_1.7-6        httr_1.4.9          crosstalk_1.2.2    
## [19] viridisLite_0.4.3   scales_1.4.0        textshaping_1.0.5  
## [22] jquerylib_0.1.4     cli_3.6.6           crayon_1.5.3       
## [25] rlang_1.3.0         tokenizers_0.3.0    bit64_4.8.6        
## [28] withr_3.0.3         cachem_1.1.0        yaml_2.3.12        
## [31] otel_0.3.0          parallel_4.6.2      tools_4.6.2        
## [34] tzdb_0.5.0          vctrs_0.7.3         R6_2.6.1           
## [37] lifecycle_1.0.5     bit_4.6.0           htmlwidgets_1.6.4  
## [40] vroom_1.7.1         pkgconfig_2.0.3     pillar_1.11.1      
## [43] bslib_0.12.0        gtable_0.3.6        Rcpp_1.1.2         
## [46] glue_1.8.1          data.table_1.18.6.1 systemfonts_1.3.3  
## [49] xfun_0.62           tidyselect_1.2.1    rstudioapi_0.19.0  
## [52] farver_2.1.2        SnowballC_0.7.1     htmltools_0.5.9    
## [55] svglite_2.2.2       rmarkdown_2.32      compiler_4.6.2     
## [58] S7_0.2.2