Handle Missing Values in Vectors

Learn how to handle missing values in descriptive statistics using R.

Missing values

The artificial variable v1 doesn’t have any missing value (v1 <- c(1, 2, 0, 2, 4, 5, 10, 1)). However, missing values are common in real-world data. What happens when missing values are present? This question is relevant both when we compute descriptive statistics for a vector and when we want to know how many missing or non-missing values are present in a vector.

Suppose we create a new variable called v2, which is identical to v1 except that v2 has two missing values. In R, the default missing value is denoted by NA. So, we replace two observations in v1 with NA to generate v2.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy