[R] selecting rows based on multiple criteria

arun smartpink111 at yahoo.com
Wed May 1 15:09:48 CEST 2013

#[1]  2 11 12

----- Original Message -----
From: Enrico R. Crema <enryu_crema at yahoo.it>
To: r-help at r-project.org
Sent: Wednesday, May 1, 2013 7:54 AM
Subject: [R] selecting rows based on multiple criteria

Dear List, 

I am struggling with the following problem. 

Suppose I have the following data.frame:


and I want to extract the row numbers of those matching the criteria defined by the following data.frame:


the result should return in this case:


All I managed to do is the following:

which(data coord$x%in%choice$x & coord$y%in%choice$y);

which returns c(1,2,11,12)... which includes also the first row... 

Any thoughts?

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list