O'Reilly logo

Data Analysis with R - Second Edition by Tony Fischetti

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Complete case analysis

This method, also called list-wise deletion, is a straightforward procedure that simply removes all rows or elements containing missing values prior to the analysis. In the univariate case—taking the mean of the drat column, for example—all elements of drat that are missing would simply be removed:

mean(miss_mtcars$drat) 
[1] NA 
mean(miss_mtcars$drat, na.rm=TRUE) 
[1] 3.63 

In a multivariate procedure—for example, linear regression predicting mpg from am, wt, and qsec—all rows that have a missing value in any of the columns included in the regression are removed:

listwise_model <- lm(mpg ~ am + wt + qsec, data=miss_mtcars, na.action = na.omit) ## OR # complete.cases returns a boolean vector comp <- complete.cases(cbind(miss_mtcars$mpg, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required