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,
...
)
A short label for a value in a vector
The raw value found in the respective vector
A longer-form label for the value, if extra context for that label is needed
A reference to another `code` in another `coding` object for recoding purposes.
Whether this `code` represents a missing response
Any extra metadata
A `code` object that contains the key-value map of label to value
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