This message is not a problem... It is only attributes that the function puts in the resulting matrix. An array with these attributes will continue to behave like an array. Just ignore them.
That said, if you still want to delete it, you can do the following:
a <- matrix(rep(c(NA, 1:4), each = 20), ncol = 10, byrow = T)
b <- na.omit(a)
attr(b, "na.action") <- NULL
b
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 1 1 1 1 1 1 1 1 1 1
[2,] 1 1 1 1 1 1 1 1 1 1
[3,] 2 2 2 2 2 2 2 2 2 2
[4,] 2 2 2 2 2 2 2 2 2 2
[5,] 3 3 3 3 3 3 3 3 3 3
[6,] 3 3 3 3 3 3 3 3 3 3
[7,] 4 4 4 4 4 4 4 4 4 4
[8,] 4 4 4 4 4 4 4 4 4 4
In the line that has attr(b, "na.action") <- NULL
you are assigning NULL
the attribute that the function na.omit
added, which is equivalent to excluding it.
A more concise but less intuitive way is to do:
b <- na.omit(a)[T,T]
This results in a matrix with no extra attributes by a function feature [
, which can be found in the document (?"["
):
Subsetting (except by an Empty index) will drop all Attributes except
Names, dim and dimnames.