Skip to course content
Free R statistics course

Statistical Data Analytics with R

Unit 02.02: Complete-case analysis is a decision

Dropping incomplete rows is a legitimate analysis. It is an analysis of a different population from the one you set out to study.

Complete-case analysis is a decision, not a default

Most R functions drop missing values silently or refuse to run. Either way the effective sample changes, and the report rarely says so.

The question that decides whether it matters is whether the missingness is related to the outcome. If people with the worst results are the ones who did not respond, complete cases give you the best-off subset and every estimate is biased. Nothing in the data can settle this, because the missing values are precisely what you cannot see.

What the data can show is whether missingness is *balanced across groups*. An imbalance is evidence that it is not random, and it is one of the few diagnostics available.

This block counts the missingness by group before dropping anything.

suppressPackageStartupMessages(library(dplyr))

d <- data.frame(
  id      = 1:10,
  group   = rep(c("A", "B"), each = 5),
  outcome = c(41, 38, NA, 44, 40, 52, NA, NA, 49, 51)
)

cat("Rows:", nrow(d), " Missing outcome:", sum(is.na(d$outcome)), "\n")
print(d |> group_by(group) |> summarise(n = n(), missing = sum(is.na(outcome)),
                                        .groups = "drop"))

cat("\nMissingness is not balanced: 1 in A, 2 in B.\n")

complete <- d |> filter(!is.na(outcome))
cat("\nComplete-case analysis keeps", nrow(complete), "of", nrow(d), "rows.\n")
cat("Group means, complete cases:\n")
print(complete |> group_by(group) |> summarise(n = n(), mean = round(mean(outcome), 1),
                                               .groups = "drop"))

cat("\nThat is a valid analysis of the people who answered.\n")
cat("It is only an analysis of everyone if the missingness is unrelated to the\n")
cat("outcome -- which the data cannot tell you, and the imbalance above doubts.\n")

Three of ten outcomes are missing, and they are not balanced: 1 in group A, 2 in group B. Complete-case analysis keeps 7 rows and gives group means of 40.8 from 4 rows and 50.7 from 3. That analysis is entirely valid *for the people who answered*. Whether it says anything about everyone depends on an assumption the imbalance actively undermines.

The mistake this prevents

The mistake is na.rm = TRUE on every summary. Each call quietly uses a different subset, so the means, the standard deviations and the tests in one report can rest on different samples.

Takeaway

Count missing values by group before excluding anything. Report the effective n, state that complete-case analysis assumes the missingness is unrelated to the outcome, and flag any imbalance as evidence against it.