Message-ID: <33cd3954-3c75-40b1-a793-9a6d34abd112@email.android.com>
Date: 2013-03-08T02:24:02Z
From: Jeff Newmiller
Subject: Select rows from Data Frame with conditions
In-Reply-To: <CAGuusR9_hF7TnJbckng8xv+Tw8Sbj1SDSS6vWuHdrJ47rak=wQ@mail.gmail.com>
Something along the lines of
top100 <- A[match(B,A[,1]),]
Please provide R code with sample data and desired output. See http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Sachinthaka Abeywardana <sachin.abeywardana at gmail.com> wrote:
>Hi all,
>
>I have two dataframes. The first (A) contains all the stock prices for
>today including today. So the first column is the stock Symbol and the
>second column is the stock price. The second (B) is the symbol list in
>the
>top 100 stocks.
>
>I want to pick out from dataframe A only the rows containing the
>symbols
>from B. i.e. something like:
>
> prices <- A[A[,1]==B,2]
>
>is there any way to do this without using a for loop, I have to do this
>365
>times (i.e. for one year).
>
>Thanks,
>Sachin
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at 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.