Message-ID: <20060221214714.35887.qmail@web31301.mail.mud.yahoo.com>
Date: 2006-02-21T21:47:14Z
From: Marco Geraci
Subject: How to select only certain rows when making a new dataframe?
In-Reply-To: <e40d78ce0602210953x7668a272r3e50c8d4ec0c3240@mail.gmail.com>
I think ?merge is what you need. The help page of this
function is very....helpful
Marco
--- mtb954 at gmail.com wrote:
> Dear R-users,
>
> I have two data frames. The "FIRST" data frame has
> 100 rows, the
> "SECOND" data frame has only 50 rows.
>
> The data frames have different variables in columns
> ("VAR1," "VAR2,"
> etc) but they share a column called "ID" that
> contains a unique
> identifer linking the two data frames.
>
> I would like to make a "THIRD" data frame containing
> just the rows of
> the "FIRST" data frame that match the rows (on "ID")
> in the "SECOND"
> data frame.
>
> >THIRD=data.frame(FIRST$ID,FIRST$VAR1,FIRST$VAR2)
>
> How can I modify this line to include in "THIRD"
> just the rows in
> "FIRST" that match the rows in "SECOND"? (i.e.,
> contain the same value
> in the shared "ID" column).
>
> Thanks! Mark
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>