measurement | R Documentation |
Functions to extract information about the measurement levels of a variable (if already present), or to specify such measurement levels.
measurement(x)
measurement(x) <- value
x |
A declared vector. |
value |
A single character string of measurement levels, separated by commas. |
This function creates an attribute called "measurement"
to a declared
This object, as an optional feature, at this point for purely aesthetic
reasons. attribute might become useful in the future to (automatically)
determine if a declared object is suitable for a certain statistical
analysis, for instance regression requires quantitative variables, while some
declared objects are certainly categorical despite using numbers to denote
categories.
It distinguishes between "categorical"
and "quantitative"
types of
variables, and additionally recognizes "nominal"
and "ordinal"
as
categorical, and similarly recognizes "interval"
, "ratio"
,
"discrete"
and "continuous"
as quantitative.
The words "qualitative"
is treated as a synonym for "categorical"
,
and the words "metric"
and "numeric"
are treated as synonyms for
"quantitative"
, respectively.
A character vector.
Other labelling functions:
drop_undeclare
,
labels()
x <- declared(
c(-2, 1:5, -1),
labels = c(Good = 1, Bad = 5, DK = -1),
na_values = c(-1, -2),
label = "Test variable"
)
x
measurement(x)
# automatically recognized as categorical
measurement(x) <- "ordinal"
measurement(x)
# the same with
measurement(x) <- "categorical, ordinal"
set.seed(1890)
x <- declared(
sample(c(18:90, -91), 20, replace = TRUE),
labels = c("No answer" = -91),
na_values = -91,
label = "Respondent's age"
)
# automatically recognized as quantitative
measurement(x) <- "discrete"
measurement(x)
# the same with
measurement(x) <- "metric, discrete"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.