RE: [R] how to get such a subset of a matrix?

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Fri 06 May 2005 - 23:42:03 EST


Try:

  a[rowSums(is.na(a)) <= 2, ]

Andy

> From: Xiao Shi
>
> Hi everybody,
> Maybe this question is quite simple but i just don't know how
> to make it.
> I have a matrix a somewhat like this one but bigger:
> > a
> f g h i j k
> a NA NA 11 16 21 26
> b NA NA 12 17 22 27
> c NA 8 13 18 23 28
> d NA 9 14 19 24 29
> e NA 10 15 20 25 30
> And i want to get the rows which at most have 2 Na.
> Thanks in advance.
> Shi Jiantao
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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
>
>
>



R-help@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 Received on Fri May 06 23:58:27 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:37 EST