defined | R Documentation |
The defined
constructor creates the objects of this class, which
are semantically extended vectors inherited from
haven::labelled
.
defined(
x,
labels = NULL,
label = NULL,
unit = NULL,
definition = NULL,
namespace = NULL
)
is.defined(x)
## S3 method for class 'haven_labelled_defined'
as.character(x, ...)
## S3 method for class 'haven_labelled_defined'
summary(object, ...)
x |
A vector to label. Must be either numeric (integer or double) or character. |
labels |
A named vector or |
label |
A short, human-readable description of the vector or |
unit |
A character string of length one containing the
unit of measure or |
definition |
A character string of length one containing a
linked definition or |
namespace |
A namespace for individual observations or categories or |
... |
Further parameters for inheritance, not in use. |
object |
An R object to be summarised. |
as.character
coerces a defined vector into a character vector.
summary
summarises the defined
vector.
For more details, please check the vignette("defined", package = "dataset")
vignette.
The constructor defined
returns a vector with defined
value labels, a variable label, an optional unit of measurement and linked
definition.
is.defined
returns a logical value, stateing if the object is of
class defined
.
Other defined metadata methods and functions:
var_label()
,
var_namespace()
,
var_unit()
gdp_vector <- defined(
c(3897, 7365, 6753),
label = "Gross Domestic Product",
unit = "million dollars",
definition = "http://data.europa.eu/83i/aa/GDP"
)
# To check the s3 class of the vector:
is.defined(gdp_vector)
# To print the defined vector:
print(gdp_vector)
# To summarise the defined vector:
summary(gdp_vector)
# Subsetting work as expected:
gdp_vector[1:2]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.