I am a bit confused as to what the following command does:
evens <- df$nums %% 2 == 0

In my matrix example, let's say I am looking for the variable(s) BC and I
want R to return all the rows with that value... or If I want a value such
as 33.543.  How would I get it to do that?   Just a single value in the
latter case.  I have already converted it to a data frame.

Thanks a lot!

On Tue, Jul 21, 2009 at 11:34 AM, Steve Lianoglou <
mailinglist.honey...@gmail.com> wrote:

>
> On Jul 21, 2009, at 1:47 PM, Mehdi Khan wrote:
>
>  Hello all,
>>
>> I have a seemingly simple question which I have searched for an answer for
>> for a few hours without luck.  I have a matrix of both values and
>> characters
>> with thousands of rows.  I would like to run a search of this matrix for
>> certain values and would like the search to retrieve the entire row.  How
>> would I accomplish this?
>>
>
> Oh, values! Woops
>
> Like so?
>
> df <- data.frame(nums=1:10, words=c("Abelonian",
>    "abeltree",
>    "Abencerrages",
>    "abenteric",
>    "abepithymia",
>    "Aberdeen",
>    "aberdevine",
>    "Aberdonian",
>    "Aberia",
>    "aberrance"))
>
> evens <- df$nums %% 2 == 0
> df[evens,]
>
> You can build such an indexing vector (like evens) in a number of different
> ways to suite your problem.
>
>
> -steve
>
> --
> Steve Lianoglou
> Graduate Student: Physiology, Biophysics and Systems Biology
> Weill Medical College of Cornell University
>
> Contact Info: 
> http://cbio.mskcc.org/~lianos/contact<http://cbio.mskcc.org/%7Elianos/contact>
>
>
>
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to