codes | R Documentation |
Get the codes belonging to given labels
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))
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. |
to_codes
has the same functionality as a call to codes.default
.
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 as.label
for an alternative in comparisons.
data(objectcodes)
data(objectsales)
objectsales$product <- code(objectsales$product, objectcodes)
codes(c("Hammer", "Electric Drill"), objectcodes)
codes(c("Hammer", "Electric Drill"), cl(objectsales$product))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.