This message is not a problem ... These are just attributes that the function places on the resulting array. An array with these attributes will continue to behave as 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
to the attribute that the na.omit
function added, which is equivalent to deleting it.
A more concise but less intuitive way is to do:
b <- na.omit(a)[T,T]
This results in an array without extra attributes by a characteristic of the [
function, which can be found in the document ( ?"["
):
Subsetting (except for an empty index) will drop all attributes except
names, dim and dimnames.