How to Check for NA Values in a Data Frame in R

· 1 min read · Updated March 14, 2026 · beginner
r data-analysis na missing-values

Missing values (NA) are common in real data. Here are efficient ways to detect them.

Check for NA in a vector

x <- c(1, 2, NA, 4, 5)

is.na(x)
# [1] FALSE FALSE  TRUE FALSE FALSE

# Count NA values
sum(is.na(x))
# [1] 1

Check for NA in a data frame

df <- data.frame(
  name = c("Alice", "Bob", NA, "Diana"),
  age = c(25, NA, 35, 40)
)

# Count NA per column
colSums(is.na(df))
# name  age 
#    1    1 

# Total NA in entire data frame
sum(is.na(df))
# [1] 2

With dplyr

library(dplyr)

df <- data.frame(
  name = c("Alice", "Bob", NA, "Diana"),
  age = c(25, NA, 35, 40)
)

# Find rows with any NA
df %>%
  filter(if_any(everything(), is.na))
#   name age
# 1 Bob  NA
# 2 <NA>  35

Using complete.cases

df <- data.frame(
  x = c(1, 2, NA, 4),
  y = c(NA, 2, 3, 4)
)

# Get only complete rows
df[complete.cases(df), ]
#   x y
# 4 4 4

See Also