Due Monday, November 2, 11:59 PM: Extended Codebook and Reliability Protocol
A project workspace that holds the study in one folder
Your codebook installed as the rendered rulebook
The shared Twitch example data loaded and inspected
Assigned reading: Munafo et al. (2017)
Tonight is the gentlest possible evening in R: you load data and look at it. Every step you practice on the example data is a step you repeat on your own source.
Why the Workspace Comes First
Reproducible research depends on traceability
Files live in known places, not in commands typed once
A project is one folder for one study
Data, code, codebook, and report travel together
Nothing depends on a file that exists only on your laptop
Your Week 15 White Paper renders from this folder
Scaffolding the Project
Download the starter and save it in the top folder of your workspace, next to README.md
The scaffold decides where every file goes and what it is named. The five numbered files are the sections of your White Paper, already in order. An hour lost to file layout is an hour not spent on the study.
Confirming the Stack
Run AURA: Check my setup from the Command Palette
It checks R, Quarto, Git, and every package this course uses
If a line says MISSING, run AURA: Install what is missing
You met this check in Chapter 2, at installation
Run it as a habit, every time you open a project
It reports a missing piece before that piece interrupts you
The Codebook Becomes a Document
One of the scaffolded files is codebook/codebook.qmd
Start it from your Definitions Practice: each variable’s definitions and decision rules
Add a version line and a date
A codebook that renders has no broken structure
What changes tonight is the codebook’s status, not its content
It stops being a sketch and becomes the instrument
What Monday Asks For
One document, two headed parts: Extended Codebook and Reliability Protocol
The codebook, 1,200 to 2,000 words
The reliability protocol, 500 to 900 words
The protocol’s five parts: the statistic and its threshold, the stability procedure and its re-code subsample, when it fails and how you report it, single-coder safeguards, and the second-coder counterfactual
The template carries every part as a heading:Word or Quarto
The Quarto version can serve as your codebook/codebook.qmd
Function: a named piece of code that does one job each time you call it, by writing its name followed by parentheses. Example: v2v::twitch_chat() hands back the chat table.
Whatever goes inside the parentheses tells the function what to work on, such as the file read_csv() should read
Why a Function Call, Not a File Path
A new user’s first encounter with data is usually a pile of file-path errors
These functions reach inside the package and hand the data back
There is no path for you to get wrong
The working sample is not the entire 2018 collection
The full collection runs to tens of millions of rows
What ships with the package is a working sample: real, and fast
Your own source will be loaded from a file, with a path, using read_csv()
Every step after loading is the same
The Companion Writes the Loading Block
The block arrives with its comments, so it can sit in a graded script
It ends with glimpse() on each table, the look at the data the next slides read
Provenance: a record of where your data came from and everything done to it since, so a stranger could trace it back to its source. Example: the platform, the channels, the dates, and how the messages were saved.
That record is written before the first line of analysis runs
“I collected Twitch chat data” is not a methods section
Replication requires exact knowledge of what was done, and the provenance record is that knowledge
What a Provenance Sentence Looks Like
I collected 14 days of Twitch chat from the top 10 most-viewed streams in the Just Chatting category, using Twitch API v2, between 2024-01-15 and 2024-01-28, saving raw JSON responses to data/raw/ before any processing.
Every clause in that sentence is something a replicator would otherwise have to guess. Write the same kind of sentence for your own source, whatever the platform.
Munafo on Usability
“Poor usability reflects difficulty in evaluating what was done, in reusing the methodology to assess reproducibility, and in incorporating the evidence into systematic reviews and meta-analyses.”
Munafo et al. (2017, p. 4)
A study that can be found is not the same as a study that can be used
A study can be public, cited, and still impossible to evaluate
Exercise: Usability, Not Discoverability
Munafo et al. (2017)
“Poor usability reflects difficulty in evaluating what was done, in reusing the methodology to assess reproducibility, and in incorporating the evidence into systematic reviews and meta-analyses.”
Munafo et al. (2017, p. 4)
Which failure is worse for the field: a study nobody can find, or a study nobody can evaluate? Give one reason
Name one thing your provenance statement owes a stranger who wants to repeat your study
Name one step in your own workflow that a stranger could not repeat today
Provenance for Other Kinds of Studies
A study of match analysis videos on YouTube
The channels, the upload window, the date you collected, and how you chose each video
A study of post-game interviews and fan comments on X
The interviews’ source, the search terms for the comments, and the date range
A study of campaign posts on Instagram and their comments
The accounts, the posting dates, how many comments per post, and their sort order
Each clause answers a question a replicator would otherwise have to guess
What the Provenance Record Includes
For data collected from a platform, whether through an API or by export, the record names:
The data source and the API version or export tool
The date and time range of collection
Any filters, keywords, or account selectors applied
The format in which the raw data was saved
The git commit at which the raw data was frozen
Item 5 is the audit trail: never re-run collection over a file a script already uses.
The table has 32,276 rows, one snapshot of one stream in each
Row 1 is the row Chapter 2 opened with, at 27,934 viewers
Row 5 is the same channel minutes later, at 28,076 viewers
title is as messy as chat
One title holds a line break inside the string and a long run of digits
Noticing this before any analysis is the reason first contact exists.
Counting
Run AURA: Write R code, then pick Count rows per group (count) under R2 Data
Choose the streams table, then the game column. The Companion writes:
streams %>%count(game, sort =TRUE)
# A tibble: 61 × 2
game n
<chr> <int>
1 Art 5298
2 Fortnite 3682
3 Just Chatting 2474
…
R prints ten rows, then # ℹ 51 more rows. Read %>% as “then”.
What the Count Tells You
The example streams cover 61 distinct games, more than a study can examine one by one
A handful of games hold most of the snapshots, and the long tail holds the rest
Art tops the list, and one channel produced all of it
All 5,298 Art snapshots come from bobross, a channel restreaming old episodes of The Joy of Painting
So the count shows one popular channel in one week of November 2018, not that Art is popular in general
A category total can be one source in disguise: check who produced it before you report it
count() is looking, not changing. The table is exactly as loaded.
Checking the Corpus
Run Count rows per group again, this time on the chat table and the channel column
The result has 50 rows, one per channel
Chapter 1 described fifty channels, and here they are
The same count on streams gives the same fifty
The data you loaded is the corpus the book described, no more and no less
Run the same counts on your own source to confirm that it is what you were told it is.
Reading the Data Against the Codebook
Open the codebook beside the glimpse() output and check, variable by variable, whether the data contains what each variable needs. For the book’s example codebook:
Message target: coded from the message text plus the sender. Both columns exist, so the variable is supported
Message length: a character count of message, so supported
Contains emote: read from the same column, so supported
Then run the same check for every variable in your own codebook against your own source. It is far better to confirm now than to find a missing column in the middle of coding.
The Same Check on Other Studies
Video and comments as two tables
Post-game interviews with fan comments, or a documentary series with its viewers’ comments
Which column links each comment to the video it answers?
Coding from a video timeline
Match analysis videos on YouTube
Does your record hold the time of each segment, or only the video’s length?
Comments under campaign posts
Does each comment row carry the post it sits under, and whether it is a reply?
The Wrinkle Worth Carrying Into the Codebook
A message begins “@xQcOW”, and the channel column on that row reads “xqcow”
The display name the viewer typed differs from the stored login name
A rule that matches on the channel name must allow for differences in capitalization
Fix the rule in the codebook now, before a single case is coded
A Second Worked Example: The VR Codebook
One real study, from store pages to a published finding (Foxman et al., 2022)
The codebook as it should be written, beside where practice fell short