
Create a dic vector with metadata attributes
dic.RdFactory function to create a dic vector with appropriate attributes.
This function performs parsing and validation of the provided metadata.
It is recommended to use this function to create dic objects rather than
manually setting attributes.
Usage
dic(
x,
item_name = NULL,
item_label = NULL,
values = NULL,
value_labels = NULL,
missing = NULL,
weight = 1,
type = NULL,
recodes = NULL,
class = "item",
...,
dic_attributes = NULL,
.coerce_class = TRUE,
.format_date = "%Y-%m-%d"
)Arguments
- x
A vector.
- item_name
Character.
- item_label
Character.
- values
Numeric or character vector with values. The vector can be named.
- value_labels
Character of the form
value = label; value2 = label2.- missing
Numeric or character vector with values.
- weight
numeric.
- type
defaults to data type of x.
- recodes
Recoding information e.g.
4 = 1, .default = 0.- class
default is "item".
- ...
Additional attributes to be added to the dic attribute list.
- dic_attributes
Optional pre-built attribute list (skips parsing if given).
- .coerce_class
If TRUE, coerce x to match
type.- .format_date
Date format for coercion from character -> Date.
Details
Details:
If
item_nameis missing, it is derived from the variable name in the calling environment.If
typeis missing, it is estimated from the class ofx.If
valuesorvalue_labelsare provided, they are parsed according to the specifiedtype.If
.coerce_classis TRUE (default),xis coerced to match the specifiedtype.If
typeis "factor", a factor is created fromxandvalues.The resulting object is of class
dicwith appropriate attributes set.