Produces a structured codebook listing all items, their types, choice sets, scale membership, and reverse-coding status. The codebook can be rendered as HTML or Markdown.
Usage
sframe_codebook(instrument, format = c("html", "md"))Arguments
- instrument
An
sframeobject.- format
Character. Output format. Either
"html"or"md". With"md", the codebook also carries itself as Markdown text, inmarkdown, andprint()writes that text.
Value
An object of class sframe_codebook, a list with elements
instrument_meta, items_table, choices_table, scales_table,
plan_table, models_table and format, and with format = "md",
markdown: one character string holding the whole codebook as Markdown,
with a pipe table per component. Save it with
writeLines(cb$markdown, "codebook.md"). With "html", print()
shows a compact summary, and render_report() includes the codebook in a
full report.
Examples
cs <- sframe_choice_set("ag5", 1:5,
c("Strongly disagree", "Disagree", "Neutral",
"Agree", "Strongly agree"))
i1 <- sframe_item("sat_1", "Item 1", type = "likert",
choice_set = "ag5", scale_id = "sat")
i2 <- sframe_item("sat_2", "Item 2", type = "likert",
choice_set = "ag5", scale_id = "sat")
scale <- sframe_scale("sat", "Satisfaction", items = c("sat_1", "sat_2"))
instr <- sframe_instrument("Demo Survey", components = list(cs, i1, i2, scale))
cb <- sframe_codebook(instr)
print(cb)
md <- sframe_codebook(instr, format = "md")
cat(substr(md$markdown, 1, 200))
nrow(sframe_get_items(cb))
nrow(sframe_get_scales(cb))