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(___, ___, ___))