Skip to contents

Accessors for the parts of an instrument, a codebook, or a report. They replace reaching into the object with $, which ties user code to the internal layout.

Value

A list for sframe_meta() and sframe_plan() on an instrument, an sf_component_list for the component accessors on an instrument, and a data frame for any of them on a codebook. See the table above.

Details

What each one gives back depends on what it is asked. Given an instrument, the component accessors return the component objects as an sf_component_list, which prints as a list and is subset with [ and [[. Given a codebook, the same verbs return the table the codebook already holds, a plain data frame with one row per item, scale, choice set, model or plan block.

AccessorOn an sframeOn an sframe_codebook
sframe_meta()list of metadatalist of metadata
sframe_get_items()sf_component_list of itemsdata frame of items
sframe_get_scales()sf_component_list of scalesdata frame of scales
sframe_get_choice_sets()sf_component_list of choice setsdata frame of choice sets
sframe_get_branches()sf_component_list of branching rulesuse the instrument
sframe_get_attention_checks()sf_component_list of checksuse the instrument
sframe_get_models()sf_component_list of modelsdata frame of models
sframe_plan()list of plan blocksdata frame of plan blocks

as.data.frame() on an instrument gives its items as a table, which is one part of it. A component list remains a list. For every table an instrument can produce, use sframe_codebook().

Examples

cs    <- sframe_choice_set("ag5", 1:5,
           c("Strongly disagree", "Disagree", "Neutral",
             "Agree", "Strongly agree"))
item  <- sframe_item("sat_1", "The service met my expectations.",
                 type = "likert", choice_set = "ag5", scale_id = "sat")
scale <- sframe_scale("sat", "Satisfaction", items = "sat_1")
instr <- sframe_instrument("Demo Survey", components = list(cs, item, scale))

sframe_meta(instr)$title
sframe_get_items(instr)
sframe_get_scales(instr)[["sat"]]
as.data.frame(instr)