The most fundamental components of a `code` object are the `label` and `value` elements. A `code` object is essentially a key-value tuple that has some extra metadata.

code(
  label,
  value,
  description = label,
  links_from = label,
  missing = FALSE,
  ...
)

Arguments

label

A short label for a value in a vector

value

The raw value found in the respective vector

description

A longer-form label for the value, if extra context for that label is needed

links_from

A reference to another `code` in another `coding` object for recoding purposes.

missing

Whether this `code` represents a missing response

...

Any extra metadata

Value

A `code` object that contains the key-value map of label to value

Examples

code("Yes", 1)
#> <Code>
#> label: 'Yes'
#> value: 1
code("No", 0)
#> <Code>
#> label: 'No'
#> value: 0
code(
  "No response", -88,
  description = "Participant ignored question when prompted",
  missing = TRUE
)
#> <Code>
#> label: 'No response'
#> value: -88
#> description: 'Participant ignored question when prompted'
#> Represents a missing value
code("Missing", NA, links_from = c("Refused", "Absent"))
#> <Code>
#> label: 'Missing'
#> value: NA
#> linking from: ['Refused', 'Absent']
#> Represents a missing value