Continuing our series on cleaning up R data frames with missing values, we come to the na omit function. This is probably the easiest way to purge your r data frame of incomplete data.
na.omit() – remove rows with missing values
Usage is simple. Pass the data frame you want to evaluate to na.omit() and it will return a list without any rows that contain NA values.
# na.omit in R example completerecords <- na.omit(datacollected)
- Create subsets of rows using the complete.cases() function
- Replace missing values in place using is.na (by setting them to zero, but your needs may vary)