How do you handle missing values in R using na.rm, is.na, and complete.cases?

Quick Overview

Asks how to work with missing values in R using the na.rm argument, is.na() and complete.cases(). Tests whether you can compute summaries despite NAs, count, filter and replace them, avoid the == NA trap, and judge when dropping incomplete rows biases an analysis.

How do you handle missing values in R using na.rm, is.na, and complete.cases?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

How do you handle missing values in R using `na.rm`, `is.na`, and `complete.cases`? ```hint Start from one NA Work out what `mean(c(1, NA, 3))` returns and why. The same reason explains why some obvious ways of searching for missing values come back empty. ``` ### What a Strong Answer Covers - What each of the three tools does and what it returns - Why comparing with `== NA` fails to find missing values - How to count, filter and replace missing values - What dropping incomplete rows costs and when it can bias an analysis - How other R functions treat missing values by default ### Follow-up Questions - How does `is.na()` treat `NaN`, and how do you tell `NA` and `NaN` apart? - `lm()` ran without errors on a data frame with missing values. What happened to those rows? - When is dropping incomplete rows a bad idea, and what would you do instead?

Overview: Asks how to work with missing values in R using the na.rm argument, is.na() and complete.cases(). Tests whether you can compute summaries despite NAs, count, filter and replace them, avoid the == NA trap, and judge when dropping incomplete rows biases an analysis.

PracHub logo
General
Nov 25, 2026
easyData ScientistOtherData Manipulation (SQL/Python)
0
0

How do you handle missing values in R using na.rm, is.na, and complete.cases?

What a Strong Answer Covers Guidance

  • What each of the three tools does and what it returns
  • Why comparing with == NA fails to find missing values
  • How to count, filter and replace missing values
  • What dropping incomplete rows costs and when it can bias an analysis
  • How other R functions treat missing values by default

Follow-up Questions Guidance

  • How does is.na() treat NaN , and how do you tell NA and NaN apart?
  • lm() ran without errors on a data frame with missing values. What happened to those rows?
  • When is dropping incomplete rows a bad idea, and what would you do instead?