searching for a specific row name in R

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

searching for a specific row name in R

Deepa Maheshvare
Hello Everyone,

I have a 1000 x 20 matrix. The second column of the matrix has the names of identifiers. How do I check when a certain identifier is present in the set of 1000 identifier names present in the second column. For instance, let the names of identifiers be A1,A2,...A1000. I want to check whether A501 is present .How can this be checked?

Any help will be highly appreciated.


        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: searching for a specific row name in R

Albrecht Kauffmann-2
Hello Deepa,

sum(x[,2] == "A501")
or
which(x[,2] == "A501")
.
Best,
Albrecht


--
  Albrecht Kauffmann
  [hidden email]

Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:

> Hello Everyone,
>
> I have a 1000 x 20 matrix. The second column of the matrix has the names
> of identifiers. How do I check when a certain identifier is present in
> the set of 1000 identifier names present in the second column. For
> instance, let the names of identifiers be A1,A2,...A1000. I want to
> check whether A501 is present .How can this be checked?
>
> Any help will be highly appreciated.
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: searching for a specific row name in R

R help mailing list-2
Or to return a logical value, i.e., TRUE if the column contains the value, FALSE if it does not:

  any( x[,2] == 'A501' )

-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <[hidden email] on behalf of [hidden email]> wrote:

    Hello Deepa,
   
    sum(x[,2] == "A501")
    or
    which(x[,2] == "A501")
    .
    Best,
    Albrecht
   
   
    --
      Albrecht Kauffmann
      [hidden email]
   
    Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
    > Hello Everyone,
    >
    > I have a 1000 x 20 matrix. The second column of the matrix has the names
    > of identifiers. How do I check when a certain identifier is present in
    > the set of 1000 identifier names present in the second column. For
    > instance, let the names of identifiers be A1,A2,...A1000. I want to
    > check whether A501 is present .How can this be checked?
    >
    > Any help will be highly appreciated.
    >
    >
    > [[alternative HTML version deleted]]
    >
    > ______________________________________________
    > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
    > 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.
   
    ______________________________________________
    [hidden email] mailing list -- To UNSUBSCRIBE and more, see
    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.
   

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: searching for a specific row name in R

Deepa Maheshvare
Hi Don,

When there is a list of identifier names that I want to check, the only way
is to loop over each entry stored in the list of identifier names or is
there is there any other shortcut?

Many thanks for the response?

On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don <[hidden email]> wrote:

> Or to return a logical value, i.e., TRUE if the column contains the value,
> FALSE if it does not:
>
>   any( x[,2] == 'A501' )
>
> -Don
> --
> Don MacQueen
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
> Lab cell 925-724-7509
>
>
>
> On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
> [hidden email] on behalf of [hidden email]> wrote:
>
>     Hello Deepa,
>
>     sum(x[,2] == "A501")
>     or
>     which(x[,2] == "A501")
>     .
>     Best,
>     Albrecht
>
>
>     --
>       Albrecht Kauffmann
>       [hidden email]
>
>     Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
>     > Hello Everyone,
>     >
>     > I have a 1000 x 20 matrix. The second column of the matrix has the
> names
>     > of identifiers. How do I check when a certain identifier is present
> in
>     > the set of 1000 identifier names present in the second column. For
>     > instance, let the names of identifiers be A1,A2,...A1000. I want to
>     > check whether A501 is present .How can this be checked?
>     >
>     > Any help will be highly appreciated.
>     >
>     >
>     >   [[alternative HTML version deleted]]
>     >
>     > ______________________________________________
>     > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>     > 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.
>
>     ______________________________________________
>     [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>     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.
>
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: searching for a specific row name in R

Boris Steipe
Use the %in% operator:

help('%in%')

e.g.

R > c("d", "v", "4", "s") %in% letters
[1]  TRUE  TRUE FALSE  TRUE


B.


> On 2018-08-13, at 23:36, Deepa <[hidden email]> wrote:
>
> Hi Don,
>
> When there is a list of identifier names that I want to check, the only way
> is to loop over each entry stored in the list of identifier names or is
> there is there any other shortcut?
>
> Many thanks for the response?
>
> On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don <[hidden email]> wrote:
>
>> Or to return a logical value, i.e., TRUE if the column contains the value,
>> FALSE if it does not:
>>
>>  any( x[,2] == 'A501' )
>>
>> -Don
>> --
>> Don MacQueen
>> Lawrence Livermore National Laboratory
>> 7000 East Ave., L-627
>> Livermore, CA 94550
>> 925-423-1062
>> Lab cell 925-724-7509
>>
>>
>>
>> On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
>> [hidden email] on behalf of [hidden email]> wrote:
>>
>>    Hello Deepa,
>>
>>    sum(x[,2] == "A501")
>>    or
>>    which(x[,2] == "A501")
>>    .
>>    Best,
>>    Albrecht
>>
>>
>>    --
>>      Albrecht Kauffmann
>>      [hidden email]
>>
>>    Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
>>> Hello Everyone,
>>>
>>> I have a 1000 x 20 matrix. The second column of the matrix has the
>> names
>>> of identifiers. How do I check when a certain identifier is present
>> in
>>> the set of 1000 identifier names present in the second column. For
>>> instance, let the names of identifiers be A1,A2,...A1000. I want to
>>> check whether A501 is present .How can this be checked?
>>>
>>> Any help will be highly appreciated.
>>>
>>>
>>>  [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> 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.
>>
>>    ______________________________________________
>>    [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>    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.
>>
>>
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: searching for a specific row name in R

Deepa Maheshvare
I have a hundred identifier names that I want to check from the second
column of a matrix with 6000 entries in the column.
Instead of using  R > c("d", "v", "4", "s") %in% letters , is there an
alternative?

I have the hundred identifier names that are of my interest stored in an
array.




On Tue, Aug 14, 2018 at 9:16 AM, Boris Steipe <[hidden email]>
wrote:

> Use the %in% operator:
>
> help('%in%')
>
> e.g.
>
> R > c("d", "v", "4", "s") %in% letters
> [1]  TRUE  TRUE FALSE  TRUE
>
>
> B.
>
>
> > On 2018-08-13, at 23:36, Deepa <[hidden email]> wrote:
> >
> > Hi Don,
> >
> > When there is a list of identifier names that I want to check, the only
> way
> > is to loop over each entry stored in the list of identifier names or is
> > there is there any other shortcut?
> >
> > Many thanks for the response?
> >
> > On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don <[hidden email]>
> wrote:
> >
> >> Or to return a logical value, i.e., TRUE if the column contains the
> value,
> >> FALSE if it does not:
> >>
> >>  any( x[,2] == 'A501' )
> >>
> >> -Don
> >> --
> >> Don MacQueen
> >> Lawrence Livermore National Laboratory
> >> 7000 East Ave., L-627
> >> Livermore, CA 94550
> >> 925-423-1062
> >> Lab cell 925-724-7509
> >>
> >>
> >>
> >> On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
> >> [hidden email] on behalf of [hidden email]> wrote:
> >>
> >>    Hello Deepa,
> >>
> >>    sum(x[,2] == "A501")
> >>    or
> >>    which(x[,2] == "A501")
> >>    .
> >>    Best,
> >>    Albrecht
> >>
> >>
> >>    --
> >>      Albrecht Kauffmann
> >>      [hidden email]
> >>
> >>    Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
> >>> Hello Everyone,
> >>>
> >>> I have a 1000 x 20 matrix. The second column of the matrix has the
> >> names
> >>> of identifiers. How do I check when a certain identifier is present
> >> in
> >>> the set of 1000 identifier names present in the second column. For
> >>> instance, let the names of identifiers be A1,A2,...A1000. I want to
> >>> check whether A501 is present .How can this be checked?
> >>>
> >>> Any help will be highly appreciated.
> >>>
> >>>
> >>>  [[alternative HTML version deleted]]
> >>>
> >>> ______________________________________________
> >>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >>> 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.
> >>
> >>    ______________________________________________
> >>    [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >>    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.
> >>
> >>
> >>
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> > 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.
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: searching for a specific row name in R

Bert Gunter-2
In reply to this post by Deepa Maheshvare
These seem to be basic R questions. You should spend time with an R
tutorial or two for this sort of thing. This list is here to help, but you
also need to do homework on your own if you have not already done so.

Cheers,
Bert






Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, Aug 13, 2018 at 8:36 PM, Deepa <[hidden email]> wrote:

> Hi Don,
>
> When there is a list of identifier names that I want to check, the only way
> is to loop over each entry stored in the list of identifier names or is
> there is there any other shortcut?
>
> Many thanks for the response?
>
> On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don <[hidden email]> wrote:
>
> > Or to return a logical value, i.e., TRUE if the column contains the
> value,
> > FALSE if it does not:
> >
> >   any( x[,2] == 'A501' )
> >
> > -Don
> > --
> > Don MacQueen
> > Lawrence Livermore National Laboratory
> > 7000 East Ave., L-627
> > Livermore, CA 94550
> > 925-423-1062
> > Lab cell 925-724-7509
> >
> >
> >
> > On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
> > [hidden email] on behalf of [hidden email]> wrote:
> >
> >     Hello Deepa,
> >
> >     sum(x[,2] == "A501")
> >     or
> >     which(x[,2] == "A501")
> >     .
> >     Best,
> >     Albrecht
> >
> >
> >     --
> >       Albrecht Kauffmann
> >       [hidden email]
> >
> >     Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
> >     > Hello Everyone,
> >     >
> >     > I have a 1000 x 20 matrix. The second column of the matrix has the
> > names
> >     > of identifiers. How do I check when a certain identifier is present
> > in
> >     > the set of 1000 identifier names present in the second column. For
> >     > instance, let the names of identifiers be A1,A2,...A1000. I want to
> >     > check whether A501 is present .How can this be checked?
> >     >
> >     > Any help will be highly appreciated.
> >     >
> >     >
> >     >   [[alternative HTML version deleted]]
> >     >
> >     > ______________________________________________
> >     > [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >     > 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.
> >
> >     ______________________________________________
> >     [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> >     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.
> >
> >
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: searching for a specific row name in R

Rui Barradas
In reply to this post by Deepa Maheshvare
Hello,

If you have one hundred identifier names that you want to check the
result of

id %in% column

will have length 100, the same as length(id).
If you want a shorter result you can do

which(id %in% column)

This will give you only the TRUE values.

Hope this helps,

Rui Barradas


Às 05:16 de 14/08/2018, Deepa escreveu:

> I have a hundred identifier names that I want to check from the second
> column of a matrix with 6000 entries in the column.
> Instead of using  R > c("d", "v", "4", "s") %in% letters , is there an
> alternative?
>
> I have the hundred identifier names that are of my interest stored in an
> array.
>
>
>
>
> On Tue, Aug 14, 2018 at 9:16 AM, Boris Steipe <[hidden email]>
> wrote:
>
>> Use the %in% operator:
>>
>> help('%in%')
>>
>> e.g.
>>
>> R > c("d", "v", "4", "s") %in% letters
>> [1]  TRUE  TRUE FALSE  TRUE
>>
>>
>> B.
>>
>>
>>> On 2018-08-13, at 23:36, Deepa <[hidden email]> wrote:
>>>
>>> Hi Don,
>>>
>>> When there is a list of identifier names that I want to check, the only
>> way
>>> is to loop over each entry stored in the list of identifier names or is
>>> there is there any other shortcut?
>>>
>>> Many thanks for the response?
>>>
>>> On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don <[hidden email]>
>> wrote:
>>>
>>>> Or to return a logical value, i.e., TRUE if the column contains the
>> value,
>>>> FALSE if it does not:
>>>>
>>>>   any( x[,2] == 'A501' )
>>>>
>>>> -Don
>>>> --
>>>> Don MacQueen
>>>> Lawrence Livermore National Laboratory
>>>> 7000 East Ave., L-627
>>>> Livermore, CA 94550
>>>> 925-423-1062
>>>> Lab cell 925-724-7509
>>>>
>>>>
>>>>
>>>> On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <
>>>> [hidden email] on behalf of [hidden email]> wrote:
>>>>
>>>>     Hello Deepa,
>>>>
>>>>     sum(x[,2] == "A501")
>>>>     or
>>>>     which(x[,2] == "A501")
>>>>     .
>>>>     Best,
>>>>     Albrecht
>>>>
>>>>
>>>>     --
>>>>       Albrecht Kauffmann
>>>>       [hidden email]
>>>>
>>>>     Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
>>>>> Hello Everyone,
>>>>>
>>>>> I have a 1000 x 20 matrix. The second column of the matrix has the
>>>> names
>>>>> of identifiers. How do I check when a certain identifier is present
>>>> in
>>>>> the set of 1000 identifier names present in the second column. For
>>>>> instance, let the names of identifiers be A1,A2,...A1000. I want to
>>>>> check whether A501 is present .How can this be checked?
>>>>>
>>>>> Any help will be highly appreciated.
>>>>>
>>>>>
>>>>>   [[alternative HTML version deleted]]
>>>>>
>>>>> ______________________________________________
>>>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>>>> 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.
>>>>
>>>>     ______________________________________________
>>>>     [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>>>     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.
>>>>
>>>>
>>>>
>>>
>>>        [[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
>>> 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.
>>
>>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.
>

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.
Reply | Threaded
Open this post in threaded view
|

Re: searching for a specific row name in R

R help mailing list-2
In reply to this post by Deepa Maheshvare
It depends on what you want to check. There are a lot of things you can check without looping.

For example, if you want to check whether all of the first letters of the identifier names are "A", you could do
  table( substr(idnames,1,1))
to show you all of the first letters, and how many there are of each.

Like Bert said, some tutorials would be good. Even better would be to find someone nearby who knows R really well. I think R is probably difficult to learn all on one's own.

Small suggestion: be careful about using the word "list" in statements like "a list of identifier names".  It's ok in ordinary English, but in R a "list" is a special kind of data structure. Better to say "a vector of identifier names".

-Don

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509



From: Deepa <[hidden email]>
Date: Monday, August 13, 2018 at 8:36 PM
To: "MacQueen, Don" <[hidden email]>, array R-help <[hidden email]>
Subject: Re: [R] searching for a specific row name in R

Hi Don,

When there is a list of identifier names that I want to check, the only way is to loop over each entry stored in the list of identifier names or is there is there any other shortcut?

Many thanks for the response?

On Mon, Aug 13, 2018 at 8:18 PM, MacQueen, Don <[hidden email]<mailto:[hidden email]>> wrote:
Or to return a logical value, i.e., TRUE if the column contains the value, FALSE if it does not:

  any( x[,2] == 'A501' )

-Don
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509



On 8/13/18, 12:09 AM, "R-help on behalf of Albrecht Kauffmann" <[hidden email]<mailto:[hidden email]> on behalf of [hidden email]<mailto:[hidden email]>> wrote:

    Hello Deepa,

    sum(x[,2] == "A501")
    or
    which(x[,2] == "A501")
    .
    Best,
    Albrecht


    --
      Albrecht Kauffmann
      [hidden email]<mailto:[hidden email]>

    Am Mo, 13. Aug 2018, um 07:10, schrieb Deepa Maheshvare:
    > Hello Everyone,
    >
    > I have a 1000 x 20 matrix. The second column of the matrix has the names
    > of identifiers. How do I check when a certain identifier is present in
    > the set of 1000 identifier names present in the second column. For
    > instance, let the names of identifiers be A1,A2,...A1000. I want to
    > check whether A501 is present .How can this be checked?
    >
    > Any help will be highly appreciated.
    >
    >
    >   [[alternative HTML version deleted]]
    >
    > ______________________________________________
    > [hidden email]<mailto:[hidden email]> mailing list -- To UNSUBSCRIBE and more, see
    > 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.

    ______________________________________________
    [hidden email]<mailto:[hidden email]> mailing list -- To UNSUBSCRIBE and more, see
    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.



        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
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.