Adds display names to the object's label table. A label belongs to a
member (frame, member) and to a variant – a free name such as
"name", "short" or a language code – so a member may carry several.
The table is sparse: frames and members without a row are shown by their
code. A row with member = NA labels the frame itself.
Arguments
- x
A
NestedScale.- labels
A
data.framewith columnsframe,member,labeland, unlessvariantis given, optionallyvariant.- variant
Single string filled into the
variantcolumn whenlabelshas none. Defaults to"label".- default
Single string naming the variant used when a lookup names none.
NULLkeeps the current default (initially the first variant attached).- overwrite
Replace the label of a (
frame,member,variant) already present.FALSE(default) makes that an error.
Details
Labels are for display. Alternative spellings to be matched belong in
the alias table, see attach_aliases_scale().
Examples
s <- attach_labels_scale(
scale_example(),
data.frame(frame = "sector", member = c("P", "S", NA),
label = c("Primary", "Secondary", "Sector"))
)
scale_labels(s)
#> frame member variant label
#> 1 sector P label Primary
#> 2 sector S label Secondary
#> 3 sector <NA> label Sector
scale_label(s, c("P", "S", "T"), frame = "sector")
#> [1] "Primary" "Secondary" "T"