Re: [R] removing all NA rows from a data.frame

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Mon, 28 May 2007 17:42:53 +0200

Taka Matzmoto wrote:
> Dear R-users,
>
> I have a data.frame having NA (e.g., 2nd, 4th rows, etc).
>
> Start End Length Variable_name
> [1,] "1" "1" "1" "a"
> [2,] NA NA NA ""
> [3,] "2" "2" "1" "b"
> [4,] NA NA NA ""
> [5,] "3" "6" "4" "c"
> [6,] "7" "10" "4" "d"
> :
> :
> :
>
> I like to remove the rows having NA in the first column ("Start")
> What is the most elegant way to do this? I think I can use for loop to
> remove.
> I am looking for a better way.

newX <- X[!is.na(X[,1]),]

Uwe Ligges

> Thanks
>
> Taka,
>
> _________________________________________________________________
>
> Hotmail.
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.



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 and provide commented, minimal, self-contained, reproducible code. Received on Mon 28 May 2007 - 15:53:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 May 2007 - 17:31:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.