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().
Este exercício faz parte do curso
Dealing With Missing Data in R
Instruções do exercício
For the pacman dataset:
- Using
replace_with_na(), replace missing values"N/A","na", and"missing"withNAfor theyear, andscorevariables. - Test to see if you have removed all the missing values using
miss_scan_count()at the end.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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(___, ___, ___))