Description Usage Arguments Details Value Examples
Use mixed labelled vectors to analyse social science data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
x |
A numeric vector to label, or a mixed labelled vector (for |
labels |
A named vector or |
na_values |
A vector of values that should also be considered as missing. |
na_range |
A numeric vector of length two giving the (inclusive) extents
of the range. Use |
label |
A short, human-readable description of the vector. |
haven |
Logical, coerce the unmixed object to class "haven_labelled". |
... |
Other arguments used by various other methods. |
The mixed_labelled
objects are very similar to the haven_labelled_spss
objects
from package haven. It has exactly the same arguments, but it features a fundamental
difference in the treatment of (declared) missing values.
In package haven, existing values are treated as if they were missing. By contrast, in package mixed the NA values are treated as existing values.
This difference is fundamental and points to an inconsistency in package haven:
while existing values can be identified as missing using the function is.na()
, they
are in fact present in the vector and other packages (most importantly the core ones) will
not know these values should be treated as missing.
Consequently, the existing values are interpreted as missing only by package haven. Statistical procedures will use those values as just like they were valid values.
Package mixed approaches the problem in exactly the opposite way: instead of treating existing values as missing, it treats (certain) NA values as existing. This way, it does not run into the risk of using values which should not be used.
The function unmix()
replaces the NA entries into their original numeric values, and
drops all attributes related to missing values: na_values
, na_range
and
na_index
.
mixed_labelled()
and as_mixed()
will return a labelled vector.
is_mixed()
will return a logical scalar.
unmix()
will return a regular vector if argument haven
is FALSE, or a
haven type of labelled vector when set to TRUE.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.