[R] R: deleting rows

Uwe Ligges ligges at statistik.uni-dortmund.de
Thu Sep 15 10:34:30 CEST 2005


Clark Allan wrote:

> hi all
> 
> hopefully some one can help.
> 
> 
> assume that i imported the following data into R (say the data frame is
> called a)
> 
> x1	x2	x3
> 1	NA	3
> 1	2	NA
> 1	2	3
> 3	NA	6
> 4	5	9
> 7	5	6
> 7	8	9
> NA	7	9
> 
> 
> How can i construct a new data frame that only contains those rows that
> does not contain the NA's? is these a quick way?
> 
> ie
> 
> x1	x2	x3
> 1	2	3
> 4	5	9
> 7	5	6
> 7	8	9
> 
> 
> in this example we can simple use a[c(-1,-2,-4,-8),] but happens if we
> have a larger dataframe?
> 
> we need to construct some kind of row indicator telling R which rows
> contains NA'S.
> 
> is there an easier method?


na.omit(a)

Uwe Ligges


> /
> allan
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html




More information about the R-help mailing list