Skip to content
Prev 16099 / 398498 Next

Subsets without NA

This function removes all rows
with at least one NA:
(x is a mtrix)
function(x)
{
        resultado <- x[!is.na(abs(x) %*% rep(1, ncol(x))),  ]
        resultado
}

i.e.:
[,1] [,2] [,3]
[1,]    1    5    9
[2,]    2    6   10
[3,]    3    7   11
[4,]    4    8   12
[,1] [,2] [,3]
[1,]   NA    5    9
[2,]    2   NA   NA
[3,]    3    7   11
[4,]    4    8   12
[,1] [,2] [,3]
[1,]    3    7   11
[2,]    4    8   12
Hope it helps

Agus

Dr. Agustin Lobo
Instituto de Ciencias de la Tierra (CSIC)
Lluis Sole Sabaris s/n
08028 Barcelona SPAIN
tel 34 93409 5410
fax 34 93411 0012
alobo at ija.csic.es
On Tue, 8 Jan 2002, Grum, Mikkel wrote:

            
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._