Last chance! 50% off unlimited learning
Sale ends in
NA
.to_na(x)
data.frame
or list
of variables
with value label attributes and defined missing value codes
(see labelled
).x
, where each value code of missing values is converted
to NA
.to_na
converts values to NA
, which are defined
as missing through the is_na
-attribute of a vector
(see labelled
). set_na
,
by contrast, converts those values to NA
that are
specified in the function's values
argument; hence,
set_na
ignores the is_na
-attribute.
Furthermore, see 'Details' in get_values
and get_na
.get_na
to get value codes of missing values.# 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))
x
get_na(x)
to_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))
x
get_na(x)
to_na(x)
# get summary
x <- labelled(c(1, 2, 1, 3, 4, 1, NA, 5),
c(Male = 1, Female = 2, Refused = 5),
c(FALSE, FALSE, TRUE))
frq(x)
Run the code above in your browser using DataLab