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"
Run the code above in your browser using DataLab