| as.codelist | R Documentation | 
Convert an object to a codelist object
as.codelist(x, ...)
## S3 method for class 'codelist'
as.codelist(x, ...)
## S3 method for class 'data.frame'
as.codelist(
  x,
  code = names(x)[1],
  label = names(x)[2],
  description = "description",
  parent = "parent",
  locale = "locale",
  missing = "missing",
  format = c("regular", "wide"),
  locales = NULL,
  locale_sep = "[-_@. ]",
  ...
)
| x | data.frame with the code list | 
| ... | used to pass extra arguments on to other methods. | 
| code | the name of the column in  | 
| label | the name of the column in  | 
| description | the name of the column in  | 
| parent | the name of the column in  | 
| locale | the name of the column in  | 
| missing | the name of the column in  | 
| format | the format of data.frame. In case of 'wide', it is assummed that columns are repeated for each locale. For example there are columns 'label_locale1' and 'label_locale2'. In case of 'regular' there are multiple rows one for each locale. | 
| locales | only used for  | 
| locale_sep | the separator separating the locale from the column name.
This is interpreted as a regular expression (see the 'split' argument of
 | 
When there is no column with the name given by label in x, a
new column 'label' is derived containing codes converted to character.
Returns a codelist object which is a data.frame with at
minimum the columns 'code' and 'label' and optionally 'description',
'parent', 'locale' and 'missing'. When x contains additional columns
these are kept.
codelist for a description of the codelist object.
# Examples below show the same codelist in both regular and wide format
dta <- data.frame(codes = c(1:3, 1:3), 
  labels = c(letters[1:3], LETTERS[1:3]), 
  locale = c("en", "en", "en", "nl" ,"nl" ,"nl"))
as.codelist(dta, format = "regular")
dta <- data.frame(codes = 1:3, labels_en = letters[1:3], 
  labels_nl = LETTERS[1:3])
as.codelist(dta, format = "wide")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.