Skip to content
Back to formatted view

Raw Message

Message-ID: <427B7277.8010305@pdf.com>
Date: 2005-05-06T13:34:47Z
From: Sundar Dorai-Raj
Subject: how to get such a subset of a matrix?
In-Reply-To: <cedaa40b050506062164a956e1@mail.gmail.com>

Xiao Shi wrote on 5/6/2005 6:21 AM:
> 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
> 


How about:

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

HTH,

--sundar