Find Missing Values in R (Example)
This page explains how to find missing values in a vector or data frame column in the R programming language.
Example Data
vec <- c(8, 1, 5, 3, NA, 5, NA, 3) # Create example data |
vec <- c(8, 1, 5, 3, NA, 5, NA, 3) # Create example data
Identify Position of NA Values in Vector
We can use the which() and is.na() functions to identify the index of each missing value:
which(is.na(vec)) # Find NA values in vector # 5 7 |
which(is.na(vec)) # Find NA values in vector # 5 7