[R] Subsets without NA

juli g. pausas juli at ceam.es
Tue Jan 8 17:42:38 CET 2002


I think

new <- na.omit(old)

should do.
`na.omit' returns the object with incomplete cases removed.

juli

"Grum, Mikkel" ha escrito:

> Is there a way of removing all rows with missing values from a data frame?
> I usually use
> subset(x, var1!="NA")
> and repeat for each variable.  It would be nice to be able to do it in one
> fell swoop.  Also, surprisingly, it doesn't always work.  Sometimes I'm left
> with an empty set even though not all rows have missing values for the
> variable.
>
> Cheers,
> mikkel
>
> Mikkel Grum, PhD
> Genetic Diversity Scientist
> International Plant Genetic Resources Institute (IPGRI)
> Sub-Saharan Africa Group
> ***
> c/o ICRAF
> PO Box 30677 Nairobi, Kenya
> Tel: 254 2 524505 / 524500
> Fax: 254 2 524501 / 524001
> m.grum at cgiar.org
> ipgri-kenya at cgiar.org
> www.ipgri.cgiar.org
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

--
Juli G. Pausas
Centro de Estudios Ambientales del Mediterraneo (CEAM)
C/ C.R. Darwin 14, Parc Tecnologic,
46980 Paterna, Valencia, SPAIN
Tel: (+ 34) 96 131 8227; Fax: (+ 34) 96 131 8190
mailto:juli at ceam.es
http://www.gva.es/ceam

GCTE Fire Network - http://www.gva.es/ceam/FireNetwork


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list