codes {codelist} | R Documentation |
Get the codes belonging to given labels
Description
Get the codes belonging to given labels
Usage
codes(x, ...)
## Default S3 method:
codes(x, codelist, locale = cl_locale(codelist), ...)
## S3 method for class 'code'
codes(x, ...)
to_codes(x, codelist, locale = cl_locale(codelist))
Arguments
x |
character vector with labels. |
... |
used to pass arguments to other methods. |
codelist |
a |
locale |
use the codes from the given locale. Should be a character vector of length 1. |
Details
to_codes
has the same functionality as a call to codes.default
.
Value
Returns a vector of codes. Will give an error when one of the labels cannot
be found in the codelist for the given locale. When x
is an object of
type 'code' the codes themselves are returned stripped from the 'code'
class and with the 'codelist' attribute removed.
See Also
See as.label
for an alternative in comparisons.
Examples
data(objectcodes)
data(objectsales)
objectsales$product <- code(objectsales$product, objectcodes)
codes(c("Hammer", "Electric Drill"), objectcodes)
codes(c("Hammer", "Electric Drill"), cl(objectsales$product))
[Package codelist version 0.1.0 Index]