Part 1: How creators frame it (videos)

1. Load data

library(tidyverse)
library(tidytext)
 
raw <- read_csv("tiktok_videos.csv", show_col_types = FALSE)

2. Clean data

# Keep needed columns, drop duplicates (same video under 2 hashtags),
# drop creator usernames for privacy
hashtag_cols <- grep("^hashtags/\\d+/name$", names(raw), value = TRUE)
 
videos <- raw |>
  distinct(webVideoUrl, .keep_all = TRUE) |>
  mutate(
    hashtags = pmap_chr(across(all_of(hashtag_cols)),
                        \(...) paste(na.omit(tolower(c(...))), collapse = " ")),
    created  = as.Date(ymd_hms(createTimeISO)),
    month    = floor_date(created, "month")
  ) |>
  select(
    video_url    = webVideoUrl,
    search_tag   = `searchHashtag/name`,
    caption      = text,
    language     = textLanguage,
    hashtags,
    created, month,
    plays        = playCount,
    likes        = diggCount,
    comments     = commentCount,
    shares       = shareCount,
    saves        = collectCount,
    is_ad        = isAd
  ) |>
  filter(language %in% c("en", "un")) |>       # English + undetected (emoji/short)
  mutate(engagement_rate = (likes + comments + shares) / pmax(plays, 1))
 
cat("Videos after cleaning:", nrow(videos), "\n")
## Videos after cleaning: 250
write_csv(videos, "tiktok_videos_clean.csv")

3. Pick videos for the Comments Scraper

# Top 40 by comment count -> paste into Apify "Post URLs"
top_for_comments <- videos |>
  filter(comments >= 20) |>
  arrange(desc(comments)) |>
  slice_head(n = 40)
 
writeLines(top_for_comments$video_url, "urls_for_comments.txt")
cat("Expected comments (100 per video max):",
    sum(pmin(top_for_comments$comments, 100)), "\n")
## Expected comments (100 per video max): 4000

4. Creator framing in captions

invest_words <- "\\b(invest\\w*|trad\\w*|stock\\w*|financ\\w*|profit\\w*|odds)\\b"
bet_words    <- "\\b(bet\\w*|gambl\\w*|wager\\w*|parlay\\w*|casino|sportsbook|addict\\w*)\\b"
 
framing <- videos |>
  mutate(
    text_all = tolower(paste(caption, hashtags)),
    invest   = str_detect(text_all, invest_words),
    bet      = str_detect(text_all, bet_words),
    frame    = case_when(
      invest & bet ~ "Both",
      invest       ~ "Investing / trading",
      bet          ~ "Betting / gambling",
      TRUE         ~ "Neither"
    )
  )
 
framing |> count(frame) |> mutate(pct = round(100 * n / sum(n), 1)) |> print()
## # A tibble: 4 × 3
##   frame                   n   pct
##   <chr>               <int> <dbl>
## 1 Betting / gambling     33  13.2
## 2 Both                   13   5.2
## 3 Investing / trading    72  28.8
## 4 Neither               132  52.8
p1 <- framing |>
  filter(frame != "Neither") |>
  count(search_tag, frame) |>
  ggplot(aes(x = search_tag, y = n, fill = frame)) +
  geom_col(position = "fill") +
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = c("Investing / trading" = "#2a6f97",
                               "Betting / gambling"  = "#d1495b",
                               "Both"                = "#9aa5b1")) +
  labs(title = "How creators frame prediction markets on TikTok",
       subtitle = "Share of captions using investing vs. betting language",
       x = "Search hashtag", y = NULL, fill = "Framing") +
  theme_minimal(base_size = 12)
ggsave("fig_caption_framing.png", p1, width = 8, height = 5, dpi = 150)
 
p1

5. Top co-occurring hashtags

top_tags <- videos |>
  separate_longer_delim(hashtags, " ") |>
  filter(hashtags != "",
         !hashtags %in% c("kalshi", "polymarket", "predictionmarkets",
                          "predictionmarket", "fyp", "foryou", "foryoupage",
                          "viral", "xyzbca", "zyxcba")) |>
  count(hashtags, sort = TRUE) |>
  slice_head(n = 15)
 
p2 <- ggplot(top_tags, aes(x = n, y = fct_reorder(hashtags, n))) +
  geom_col(fill = "#2a6f97") +
  labs(title = "Hashtags used alongside #kalshi / #polymarket",
       subtitle = "Shows what topics creators connect prediction markets to",
       x = "Number of videos", y = NULL) +
  theme_minimal(base_size = 12)
ggsave("fig_top_hashtags.png", p2, width = 8, height = 5, dpi = 150)
 
p2

Part 2: What viewers say (comments)

6. Load and clean comments

comments_raw <- read_csv("tiktok_comments.csv", show_col_types = FALSE)
 
# Link each comment to its video's search hashtag; drop usernames for privacy
viewer_comments <- comments_raw |>
  select(comment_id = cid, video_url = videoWebUrl, text,
         likes = diggCount, created = createTimeISO) |>
  left_join(videos |> select(video_url, search_tag), by = "video_url") |>
  mutate(text_lc = str_to_lower(text)) |>
  filter(!is.na(text),
         str_detect(text_lc, "[a-z]"))          # drop emoji-only comments
 
cat("Comments after cleaning:", nrow(viewer_comments),
    "from", n_distinct(viewer_comments$video_url), "videos\n")
## Comments after cleaning: 3013 from 40 videos

7. Consumer-behavior themes

Each theme is a keyword dictionary tied to a consumer behavior concept. A comment can fall into more than one theme.

themes <- tribble(
  ~theme,                         ~concept,                          ~pattern,
  "Gambling framing",             "Positioning / perception",        "\\b(bet\\w*|gambl\\w*|parlay\\w*|casino\\w*|sportsbook\\w*|wager\\w*)\\b",
  "Investing framing",            "Positioning / perception",        "\\b(invest\\w*|trading|trader\\w*|stock\\w*|portfolio|hedg\\w*)\\b",
  "Legality & regulation",        "Perceived risk (legal)",          "\\b(legal|illegal|regulat\\w*|cftc|sec|ban|banned|lawsuit|law|lawmakers)\\b",
  "Insider trading / rigged",     "Trust",                           "\\b(insider\\w*|rigged|scam\\w*|manipulat\\w*|corrupt\\w*|fixed)\\b",
  "Losses & addiction",           "Perceived risk (financial/psych)","\\b(addict\\w*|broke|debt|lost (all|my|everything)|losing|rehab)\\b",
  "Winning & money",              "Motivation",                      "\\b(won(?!['’]t)|win|winning|profit\\w*|cash(ed)? out|paid out|made \\$?\\d+)\\b",
  "Ad fatigue / skepticism",      "Persuasion knowledge",            "\\b(ad|ads|advert\\w*|sponsor\\w*|promo\\w*|commercial\\w*)\\b",
  "Youth & young people",         "Target market concern",           "\\b(young (people|men|guys|kids)|gen ?z|teen\\w*|kids|college|students?)\\b"
)
 
theme_hits <- themes |>
  mutate(n = map_int(pattern, \(p) sum(str_detect(viewer_comments$text_lc, p))),
         pct = 100 * n / nrow(viewer_comments))
 
theme_hits |> select(theme, concept, n, pct) |>
  arrange(desc(n)) |> mutate(pct = round(pct, 1)) |> knitr::kable()
theme concept n pct
Ad fatigue / skepticism Persuasion knowledge 271 9.0
Gambling framing Positioning / perception 213 7.1
Investing framing Positioning / perception 110 3.7
Legality & regulation Perceived risk (legal) 65 2.2
Winning & money Motivation 54 1.8
Insider trading / rigged Trust 53 1.8
Losses & addiction Perceived risk (financial/psych) 19 0.6
Youth & young people Target market concern 12 0.4
p3 <- ggplot(theme_hits, aes(x = pct, y = fct_reorder(theme, pct), fill = concept)) +
  geom_col() +
  geom_text(aes(label = n), hjust = -0.2, size = 3.5) +
  scale_x_continuous(labels = \(x) paste0(x, "%"), expand = expansion(mult = c(0, 0.12))) +
  labs(title = "What TikTok viewers talk about in prediction-market videos",
       subtitle = "Share of comments mentioning each theme (labels = number of comments)",
       x = "% of comments", y = NULL, fill = "Consumer behavior concept") +
  theme_minimal(base_size = 12)
p3

ggsave("fig_comment_themes.png", p3, width = 9, height = 5, dpi = 150)

8. Creators vs. viewers: investing or gambling?

Captions show how creators frame the platforms; comments show how viewers react.

inv_p <- themes$pattern[themes$theme == "Investing framing"]
bet_p <- themes$pattern[themes$theme == "Gambling framing"]
 
frame_of <- function(txt) {
  inv <- str_detect(txt, inv_p); bet <- str_detect(txt, bet_p)
  case_when(inv & bet ~ "Both", inv ~ "Investing / trading",
            bet ~ "Betting / gambling", TRUE ~ "Neither")
}
 
creator_vs_viewer <- bind_rows(
  videos |> filter(video_url %in% viewer_comments$video_url) |>
    transmute(source = "Creators (captions)",
              frame = frame_of(str_to_lower(paste(caption, hashtags)))),
  viewer_comments |> transmute(source = "Viewers (comments)", frame = frame_of(text_lc))
) |>
  filter(frame != "Neither") |>
  count(source, frame) |>
  group_by(source) |> mutate(pct = n / sum(n)) |> ungroup()
 
creator_vs_viewer |> mutate(pct = round(100 * pct, 1)) |> knitr::kable()
source frame n pct
Creators (captions) Betting / gambling 4 26.7
Creators (captions) Both 1 6.7
Creators (captions) Investing / trading 10 66.7
Viewers (comments) Betting / gambling 201 64.6
Viewers (comments) Both 12 3.9
Viewers (comments) Investing / trading 98 31.5
p4 <- ggplot(creator_vs_viewer, aes(x = source, y = pct, fill = frame)) +
  geom_col() +
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = c("Investing / trading" = "#2a6f97",
                               "Betting / gambling"  = "#d1495b",
                               "Both"                = "#9aa5b1")) +
  labs(title = "Do viewers see prediction markets the way creators frame them?",
       subtitle = "Same 40 videos; only posts using investing or betting language",
       x = NULL, y = NULL, fill = "Framing") +
  theme_minimal(base_size = 12)
p4

ggsave("fig_creator_vs_viewer.png", p4, width = 8, height = 5, dpi = 150)

9. Sentiment (Bing lexicon)

custom_stop <- tibble(word = c("kalshi", "polymarket", "trump", "lol", "bro"))
 
words <- viewer_comments |>
  unnest_tokens(word, text) |>
  anti_join(stop_words, by = "word") |>
  anti_join(custom_stop, by = "word")
 
comment_sent <- words |>
  inner_join(get_sentiments("bing"), by = "word", relationship = "many-to-many") |>
  count(comment_id, sentiment) |>
  pivot_wider(names_from = sentiment, values_from = n, values_fill = 0) |>
  mutate(score = positive - negative,
         label = case_when(score > 0 ~ "Positive", score < 0 ~ "Negative",
                           TRUE ~ "Neutral/mixed"))
 
sent_by_tag <- viewer_comments |>
  left_join(comment_sent |> select(comment_id, label), by = "comment_id") |>
  mutate(label = replace_na(label, "No sentiment words")) |>
  filter(label != "No sentiment words") |>
  count(search_tag, label) |>
  group_by(search_tag) |> mutate(pct = n / sum(n)) |> ungroup()
 
sent_by_tag |> mutate(pct = round(100 * pct, 1)) |> knitr::kable()
search_tag label n pct
kalshi Negative 297 63.1
kalshi Neutral/mixed 46 9.8
kalshi Positive 128 27.2
polymarket Negative 216 54.0
polymarket Neutral/mixed 33 8.2
polymarket Positive 151 37.8
predictionmarkets Negative 195 60.4
predictionmarkets Neutral/mixed 20 6.2
predictionmarkets Positive 108 33.4
p5 <- ggplot(sent_by_tag, aes(x = search_tag, y = pct,
                              fill = factor(label, c("Negative", "Neutral/mixed", "Positive")))) +
  geom_col() +
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = c(Negative = "#d1495b", `Neutral/mixed` = "#9aa5b1",
                               Positive = "#2a6f97")) +
  labs(title = "Comment sentiment by hashtag",
       subtitle = "Comments containing at least one Bing sentiment word",
       x = "Search hashtag", y = NULL, fill = "Sentiment") +
  theme_minimal(base_size = 12)
p5

ggsave("fig_sentiment_by_tag.png", p5, width = 8, height = 5, dpi = 150)

10. Top positive and negative words

top_sent_words <- words |>
  inner_join(get_sentiments("bing"), by = "word", relationship = "many-to-many") |>
  count(word, sentiment, sort = TRUE) |>
  group_by(sentiment) |> slice_head(n = 12) |> ungroup()
 
p6 <- ggplot(top_sent_words, aes(x = n, y = reorder_within(word, n, sentiment),
                                 fill = sentiment)) +
  geom_col(show.legend = FALSE) +
  facet_wrap(~ sentiment, scales = "free_y") +
  scale_y_reordered() +
  scale_fill_manual(values = c(negative = "#d1495b", positive = "#2a6f97")) +
  labs(title = "Words driving comment sentiment", x = "Count", y = NULL) +
  theme_minimal(base_size = 12)
p6

ggsave("fig_top_sentiment_words.png", p6, width = 9, height = 5, dpi = 150)

11. Example comments per theme (for quotes in your write-up)

set.seed(42)
examples <- themes |>
  mutate(examples = map(pattern, \(p) viewer_comments |>
                          filter(str_detect(text_lc, p), str_length(text) < 160) |>
                          slice_max(likes, n = 3, with_ties = FALSE) |>
                          select(text, likes))) |>
  select(theme, examples) |>
  unnest(examples)
 
knitr::kable(examples)
theme text likes
Gambling framing “you can bet on ANYTHING” why would i want to?? 😭 82085
Gambling framing Mind you, gambling is one of the hardest addictions to kick, literally on par with opiates and alcohol. 33344
Gambling framing people are betting on the WEATHER!!!! thats the ad I got yesterday… 25915
Investing framing Update: Two senators are calling for a federal investigation into Polymarket’s marketing practices after our reporting. 8022
Investing framing Weather, politics, stocks , wars , like what’s next whether my period will be late ?!! 2726
Investing framing Donald Trump Jr. is a strategic advisor and investor of Kalshi. 763
Legality & regulation easiest law suit ever 98347
Legality & regulation how are these ads even legal 24740
Legality & regulation This should be illegal 7260
Insider trading / rigged damn, I actually better on Kalshi that this wasn’t a scam 😭😭😭 I just lost $50 172
Insider trading / rigged Every congress and president in recent years has been corrupt 62
Insider trading / rigged Isn’t gambling a scam always? 41
Losses & addiction Mind you, gambling is one of the hardest addictions to kick, literally on par with opiates and alcohol. 33344
Losses & addiction why did we just accept that it was okay for big corporations to use human addictions to profit???😅 323
Losses & addiction My addictions are starchy carbs and TikTok. 77
Winning & money He sued and won the world cup 🏆⚽️ 1074
Winning & money The WSJ found that 0.1% of polymarket users earn 67% of the profits btw 404
Winning & money why did we just accept that it was okay for big corporations to use human addictions to profit???😅 323
Ad fatigue / skepticism Block anyone who promote it too 41945
Ad fatigue / skepticism OMG WDYM IT WAS AN AD 29300
Ad fatigue / skepticism people are betting on the WEATHER!!!! thats the ad I got yesterday… 25915
Youth & young people What’s interesting is that Polymarket is marketing to KIDS! 1395
Youth & young people and almost all the kalshi ads i get? on a mobile game that looks like this. like not a kids game necessarily but def kid friendly 152
Youth & young people Young people deserve better. Better entertainment, better more uplifting games and play and being outside, being spontaneous. 31