Friday, January 11, 2013

Introduction to R – Removing missing values

A common task in preparing you data is to remove missing values(NAs). One way to do that is to retrieve a vector of the missing values in your data, and then filter them out from your structure.
RGui (64-bit)_2013-01-09_13-17-45
If you want to filter out the missing values from more than one vector , you can use complete.cases() to get the indices that contains good data in both vectors.
RGui (64-bit)_2013-01-09_13-25-29
Here good will contain TRUE only for indices that hold good data in both vectors; FALSE otherwise. complete.cases() works with data frames also. In that case it removes any row that contains NA in any column.The returned data frame will not contain any NAs.
Stay tuned for more R notes.

No comments: