A codebook is the measurement instrument of a content analysis: construct
definitions, category boundaries, decision rules, and examples. Here it is
a first-class object – versioned, printable, hashable – that compiles
into the prompt via format_codebook(), so the instrument the model saw
is exactly the instrument in the paper's appendix.
Arguments
- name
Short name of the construct (e.g.
"populist framing").- unit
What one coding unit is (e.g.
"one parliamentary speech").- categories
A list of
cb_category()objects. Labels must be unique.- instructions
Optional free-text instructions placed before the category definitions (coder-neutral: the same text serves human coders).
- version
A version string you control (e.g.
"1.2"); bump it when the instrument changes. The content hash changes with any edit either way; the version is for humans.
Examples
cb <- codebook(
name = "populist framing",
unit = "one speech",
categories = list(
cb_category("populist", "People-vs-elite framing is present."),
cb_category("not_populist", "No people-vs-elite framing.")
),
version = "1.0"
)
cb
codebook_hash(cb)