Count the Words SOCL 3633 Research Methods · Lab 15 · Midwestern State University

On Tuesday you read ten court texts and coded them by hand. Today the computer reads all twenty. You count every word in the shared corpus, chart the most frequent ones, and then give the computer a short word list for one of your codes, so it codes the same ten texts as a second coder. Keep this page open next to RStudio, have your Tuesday coding grid in front of you, and work through the tabs in order. Submit your response sheet and your chart in the Lab 15 submission on D2L by Thursday, April 29, at 11:59 p.m.

Get set up

Checkpoint. nrow(corpus) prints 20, one row for each text.

If you missed Tuesday or lost your grid

Code the ten texts (1, 2, 3, 5, 8, 9, 10, 11, 12, and 17) for one code before Step 5: hiding or concealment, defined as "the text describes a step taken to hide the conduct or avoid detection." Write 1 or 0 for each text. It takes about ten minutes with the handout.

If something goes wrong

What you seeWhat to do
"class_corpus.csv does not exist in current working directory"The file is in a different folder, or its name is different. Check the Files pane. Then click Session, Set Working Directory, To Source File Location, and run Step 1 again.
"there is no package called 'tidytext'"Run Step 0 again and wait for it to finish. If it still fails, tell your instructor.
"Existing data has 10 rows. Assigned data has 9 rows." (or another number)Your my_codes line in Step 5 does not have exactly ten values. Count them against your grid and run it again.
A + sign in the ConsoleA parenthesis or quotation mark is missing. Press Escape in the Console, fix the line, and run it again.

Count the words: Steps 2 and 3

Step 2: one row per word

Put text in the blank in unnest_tokens(word, ____) and run the lines, then nrow(words).

unnest_tokens()
Splits each text into single words, one word per row, and makes every word lowercase. The unit of analysis changes: before this step each row was a text, and after it each row is a word.
Checkpoint. nrow(words) prints 1097: the 20 texts hold 1,097 words.

Step 3: count the words

Run count(words, word, sort = TRUE). The top of the list is "the," "to," and "a." These are stop words: words that hold sentences together but say little about the topic. Run the anti_join(stop_words, ...) lines to remove them, then count again.

Checkpoint. After removing stop words, the top five are defendant (21), sophisticated (12), means (10), defendant's (9), and conduct (6).
Look at why "defendant" is first. On the handout, every defendant's name was replaced with [the defendant] to protect privacy. The most frequent word in the corpus was partly created by how the corpus was prepared. A word count measures the texts you give it, including your own edits.

Chart them: Step 4

  1. Run the top_words lines. They keep every word that appears at least 4 times.
  2. Run the chart lines and print(words_chart).
  3. Replace the title with a short complete sentence, about ten words, that says what the words show. Run the chart lines again.
  4. In the ggsave() line, replace lastname with your last name and run it.
Bar chart of the 11 words used 4 or more times in the 20 court texts after removing stop words: defendant 21, sophisticated 12, means 10, defendant's 9, conduct 6, scheme 5, money 5, enhancement 5, structuring 4, fraud 4, account 4.
This is the chart from the answer key. Yours has the same bars and your own title. Notice what the chart cannot tell you: whether a text calls the conduct sophisticated or argues that it was not. Text 9 uses "sophisticated" to say "there is nothing sophisticated" about the conduct. The count treats both uses the same. Question 3 on the response sheet asks about this.

A word list as a second coder: Step 5

A content dictionary is a list of words that stand for one idea. The computer marks a text 1 if any word on the list appears in it, and 0 if none does. Today's list is for hiding or concealment.

  1. Run the ten, my_words, and pattern lines, then the flags lines, then flags. The word_list column shows the computer's call for each of the ten texts.
  2. Find the column on your Tuesday grid for the code closest to hiding or concealment. In the my_codes <- c(____) blank, type its ten values, 1 or 0, separated by commas, in grid order. Run it, then the next two lines.
  3. Run sum(flags$word_list == flags$my_code): the number of texts, out of 10, where you and the word list agree.
  4. Add one word beginning to my_words that you think the list is missing, such as "evad" or "avoid". Run Step 5 again from the my_words line and see whether the count changes.
Checkpoint. With the starting list, the word list marks only texts 10 and 17. The answer key codes hiding in texts 9, 10, 11, and 17, so they agree on 8 of 10. Adding "evad" and "avoid" catches text 11 and raises it to 9 of 10. Text 9 is still missed: it describes moving money so it cannot be recovered, without any word on the list.
If your class codebook has no code for hiding, pick any code on your grid and replace my_words with four to six word beginnings you think signal it. Say which code you chose in question 4.
Before you leave: save the script (File, then Save).

Lab 15 response sheet

Answer in complete sentences. Then assemble your answers and paste them into the Lab 15 submission on D2L. In the same submission, upload your chart picture. Both are due Thursday, April 29, at 11:59 p.m.

Your name
1. Texts 1 and 3 describe the same theft. One calls it "theft" and the other calls it "diversion." Did your codebook score the two texts the same way? Should it?
Three to four sentences. Use your Tuesday grid.
2. Texts 9 through 12 come from one appeals case in which the judges disagreed about the same facts. Compare the judges' disagreement with the disagreements you and your partner had. What would a coder need to know to apply your codes the way the majority would, and the way the dissent would?
Three to five sentences.
3. Name one theme from your hand coding that is visible in the word chart, and one that is not. How can a theme be present in the texts and absent from a word count?
Three to four sentences.
4. On how many of the ten texts did the word list agree with your hand codes? Name one text where they differ, and explain which measure you trust for that text and why.
Three to four sentences. Say which code you compared and which word you added.

Sources

Bernard, H. Russell, and Amber Wutich. 2026. Social Research Methods: Qualitative and Quantitative Approaches. 3rd ed. Thousand Oaks, CA: SAGE. Chapter 12.
Silge, Julia, and David Robinson. 2016. "tidytext: Text Mining and Analysis Using Tidy Data Principles in R." Journal of Open Source Software 1(3):37.
Wickham, Hadley. 2016. ggplot2: Elegant Graphics for Data Analysis. New York: Springer.

The corpus: 20 short excerpts from public federal court records in fraud cases, retrieved from CourtListener (courtlistener.com) on October 1, 2026. Full citations for each text are at the end of the Shared Corpus handout.