The Great Library Heist

A text analysis case file

Published

October 26, 2026

library(tidyverse)
library(tidytext)
library(topicmodels)
library(kableExtra)
dta <- readRDS(here::here("data/heist_books.rds"))

The crime

Case briefing

Late last night, someone broke into the library and went mad!

  • An unknown number of books were taken from their shelves.
  • Their spines were cut and every page torn loose.
  • The pieces were shuffled together and dumped into a single evidence box.
  • The covers and title pages are gone.
  • Nobody knows which scrap came from which book, how many books were taken, or what the books are.

Your assignment

You have no witnesses and no confession. All you have is the words the books left behind. Your goal is to:

  1. Work out how many books were stolen.
  2. Return every scrap to its book.
  3. Name each book.

Rules of the investigation

Rules

  • Your research team is your detective squad.
  • Every claim needs evidence you produced in R.
  • You must keep your own evidence log (quarto file). You’ll be asked to divide up the work later and everyone should be at the same point. Write notes in here as well, you’ll turn it in at the end of the investigation.
  • No outside tips. No search engines or chatbots on the scraps. That’s tampering with evidence.
  • You can talk to the tech team (aka google, your notes or our helper page) to ask for help with code functions.
  • This is a friendly competition, no rules against helping other squads. But… there has to be a winner.

The evidence box will self destruct in T-1 hour.

Clues

  • The lead detectives (Dr. D and Amy) have 6 clues available for you during this investigation.
  • Clue #1 is already provided in these instructions. Bring your answer and your code to one of the lead detectives.
  • If it’s right, you get a lead for your next step, and the next Clue.
  • Each Clue correctly solved earns your squad 1 point toward your homework grade.
  • First team to correctly name the books gets a bonus point.
  • An answer without cold hard code evidence to back it doesn’t count.

The investigation

Phase 0: Name your squad

Sign your squad into the crime scene by logging your name with the lead investigators.

Phase 1: Secure the scene

Before touching anything, take inventory of the evidence box.

  • What is a single row? What columns came with it?
  • How are scraps labeled?
ImportantClue #1

How many exhibits are in the evidence box, and what are the fewest and the most scraps any one exhibit holds? What part of a book do you think an exhibit is?

Phase 2: Dust for prints

A whole scrap is too big to compare. Break the evidence into the smallest pieces that still carry a fingerprint: individual words.

  • Split every line so each row holds one word, still tagged with its exhibit number.
  • Some filler words appear everywhere (“the,” “and,” “of”). They don’t provide us information, so clear them out.
ImportantClue #2

After the filler is cleared, which word appears most often in the whole box, and how many times?

Phase 3: Build the evidence board

Pin every exhibit to the wall and record how often each word shows up in it.

ImportantClue #3

How many rows and columns does your evidence board have, and what percent of its cells are empty?

Phase 4: Call in the profiler, size up the crew

You need an expert who has never seen these books.

  • The profiler assumes each exhibit is a blend of a fixed number of hidden sources, each with its own favorite vocabulary.
  • It works out both from the evidence board alone.
  • It needs one thing from you: how many sources to look for. Nobody knows that yet.
  • Run the profiler several times, each with a different number of sources.
  • The profiler is slow and can get side tracked. Divide the work across your squad to check for consistency in profiler results.
  • Ensure reproducibility so your profile can be reproduced in court.
ImportantClue #4

How many books were vandalized? Defend your number with evidence comparing at least three different proposed sources and two different profilers.

Phase 5: Interrogate the suspects

Using your chosen number, the profiler scores every word under every source: how strongly that word belongs there.

  • Pull out each source’s top 10 words.
  • Plot all sources side by side.
  • Look for places, objects, and activities. What kind of story does each vocabulary tell?
ImportantClue #5

Name every vandalized book. Cite the words that convinced you.

Phase 6: Attribute the exhibits to the most likely source

The profiler also scores every exhibit: what share of it seems to come from each source.

  • For each exhibit, find the source with the largest share. That’s your best match.
ImportantClue #6

Plot the shares of the five best-matched and five worst-matched exhibits. Which exhibits are hardest to place, and which sources are they split between?

Phase 7: The reveal

You have the evidence key: the true book for every exhibit.

  • What percent of exhibits did you get correct?
  • Pick an exhibit that was returned to the wrong book. Filter the evidence box for that exhibit and read some of its scraps.
  • Why do you think the profiler put it with the other book?

Case Closed - Report out

By end of week the following should be submitted to our weekly Google folder.

  1. Your most completed quarto file for the team. It does not have to render, but it should contain the majority of the evidence and findings. One file per team only. Be sure your team name is in the file name.

  2. A personal reflection on the activity.

  • How far did your squad get?
  • What did you learn and what challenges did you encounter?
  • How did your squad work through obstacles?
  • How did you contribute to your squads success? What skillsets did you provide?