replace_with_na の利用
前のデータセットから、いくつか妙な欠損値が含まれていることがわかりました。
ここでは、これらの値を replace_with_na() を使って欠損(例: NA)に置き換えて対処していきます。
この演習はコースの一部です
Rでの欠損データの扱い方
演習の手順
pacman データセットについて、次を行ってください。
replace_with_na()を使って、yearとscore変数に含まれる"N/A"、"na"、"missing"をNAに置き換えます。- 最後に
miss_scan_count()を使って、すべての欠損値を取り除けたかを確認しましょう。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# 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(___, ___, ___))