read_spss
,
read_sas
or read_stata
), where missing
values have not been replaced with NA
s after import,
or of labelled
vectors.get_na(x)
labelled
).x
,
or NULL
if x
has no missing value attribute.labelled
vectors
allow to indicate different missings through the
is_na
-attr
. Technically, these "missings" are
stored as normal values. Thus, the table
command,
for instance, would include these values by default. The
NA
etc.
Furthermore, see 'Details' in get_values
.get_labels
to get value labels, or get_values
to get values associated with labels; see set_na
to
replace specific values with NA
and to_na
to
convert missing value codes into NA
; see get_na_flags
to get a logical vector of missing flags.# create labelled factor, with missing flag
x <- labelled(c("M", "M", "F", "X", "N/A"),
c(Male = "M", Female = "F",
Refused = "X", "Not applicable" = "N/A"),
c(FALSE, FALSE, TRUE, TRUE))
get_na(x)
# create labelled integer, with missing flag
x <- labelled(c(1, 2, 1, 3, 4, 1),
c(Male = 1, Female = 2, Refused = 3, "N/A" = 4),
c(FALSE, FALSE, TRUE, TRUE))
get_na(x)
Run the code above in your browser using DataLab