merge(df1,df2)

--- On Wed, 15/8/12, Jun Shen <jun.shen.ut@gmail.com> wrote:


From: Jun Shen <jun.shen.ut@gmail.com>
Subject: [R] Subsetting rows by multiple levels of selected values
To: "R-help" <r-help@stat.math.ethz.ch>
Date: Wednesday, 15 August, 2012, 12:35 AM


Dear list,

Let's say we have a data frame as follows,

>expand.grid(a=1:5,b=c(1,5,10,20),DV=c(0.1,0.2,0.3))->df1
>df1$DV<-rgamma(60,shape=10)

columns a and b are two levels. DV is the column with values we are
interested in.

Then another data frame df2 with values as follows

data.frame(a=c(2,2,3,4,5),b=c(5,10,1,5,20))->df2

Now I want to a subset of df1 that match df2 at the both columns a and b.
Any idea?

Thanks.

Jun

    [[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.

	[[alternative HTML version deleted]]

