Message-ID: <BANLkTinQhauAN01phmmyNYEbJF39Wqki0g@mail.gmail.com>
Date: 2011-04-25T19:12:52Z
From: Ivan
Subject: extracting names from matrix according to a condition
In-Reply-To: <4DB5BBDD.1030604@ucalgary.ca>
thank you very much. worked great for me.
On Mon, Apr 25, 2011 at 8:22 PM, Peter Ehlers <ehlers at ucalgary.ca> wrote:
> On 2011-04-25 10:58, ivan wrote:
>>
>> Dear Community,
>>
>> I have a matrix with assigned colnames and rolnames as follows:
>>
>> ? ? ? ? ? ? A ? ? ? ? ? ?B
>> NR ? ?0.15 ? ? ?0,05
>> AL ? ? 0,05 ? ? ?0,05
>> . ? ? ? ? ? . ? ? ? ? ? ?.
>> . ? ? ? ? ? . ? ? ? ? ? ?.
>> . ? ? ? ? ? . ? ? ? ? ? ?.
>>
>> I want to extract the names of the rows for which A>0,1 and B<0,1. In
>> the above example this would be observation NR only. Hence the output
>> should write for instance:
>>
>> names:
>> NR
>>
>> Is this possible? Thank you very much for your help.
>
> Call the matrix m. Then
>
> ?rownames(m[ m[, "A"] > 0.1 & m[, "B"] < 0.1, , drop=FALSE ])
>
> should do what you want.
>
> Peter Ehlers
>