Using replace_with_na
Following on from the previous dataset, we now know that we have a few strange missing values.
Now, we are going to do something about it, and replace these values with missings (e.g. NA
) using the function replace_with_na()
.
Cet exercice fait partie du cours
Dealing With Missing Data in R
Instructions
For the pacman
dataset:
- Using
replace_with_na()
, replace missing values"N/A"
,"na"
, and"missing"
withNA
for theyear
, andscore
variables. - Test to see if you have removed all the missing values using
miss_scan_count()
at the end.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Print the top of the pacman data using `head()`
head(___)
# Replace the strange missing values "N/A", "na", and
# "missing" with `NA` for the variables, year, and score
pacman_clean <- replace_with_na(_____, replace = list(year = c(___, ___, ___),
score = c(___, ___, ___)))
# Test if `pacman_clean` still has these values in it?
miss_scan_count(____, search = list(___, ___, ___))