How to remove NA values from a vector in R
· 1 min read · Updated March 14, 2026 · beginner
r na missing-data dplyr tidyr
NA values represent missing data in R. Here’s how to remove them from vectors and data frames.
From a Vector
Base R
Use na.omit() or logical indexing:
x <- c(1, 2, NA, 4, NA, 6)
x_clean <- na.omit(x)
# [1] 1 2 4 6
Or with subsetting:
x_clean <- x[!is.na(x)]
With dplyr
Use na.omit() within a pipe:
library(dplyr)
x <- c(1, 2, NA, 4, NA, 6)
x_clean <- x %>% na.omit()
From a Data Frame
Base R
Remove rows with any NA:
df_clean <- na.omit(df)
dplyr
Use drop_na() from tidyr:
library(dplyr)
library(tidyr)
df_clean <- df %>% drop_na()
Drop NA from specific columns only:
df_clean <- df %>% drop_na(column_name)