Questions about missing data

matrix, na, r

Solution

`na.omit()` will take matrices (and data frames) and return only those rows with no NA values whatsoever - it takes `complete.cases()` one step further by deleting the FALSE rows for you.

> x <- data.frame(c(1,2,3), c(4, NA, 6))
> x
  c.1..2..3. c.4..NA..6.
1          1           4
2          2          NA
3          3           6
> na.omit(x)
  c.1..2..3. c.4..NA..6.
1          1           4
3          3           6

Problem

In a matrix, if there is some missing data recorded as `NA`. - how could I delete rows with `NA` in the matrix? - can I use `na.rm`?

Original source