Re: [R] Subsetting a data frame with multiple values and exclusions.

2011-10-06 Thread natalie.vanzuydam
Thanks. Such a short and sweet answer that does what it should. - Natalie Van Zuydam PhD Student University of Dundee nvanzuy...@dundee.ac.uk -- View this message in context: http://r.789695.n4.nabble.com/Subsetting-a-data-frame-with-multiple-values-and-exclusions-tp3874967p3877472.html Sen

Re: [R] Subsetting a data frame with multiple values and exclusions.

2011-10-05 Thread Dennis Murphy
Hi: Is this what you're after? f <- function(x) !any(x %in% terms_exclude) && any(x %in% terms_include) db[apply(db[, -1], 1, f), ] ind test1 test2 test3 2 ind2 227 28.0 4 ind4 3 2 1.2 HTH, Dennis On Wed, Oct 5, 2011 at 8:53 AM, natalie.vanzuydam wrote: > Hi all, > > I

[R] Subsetting a data frame with multiple values and exclusions.

2011-10-05 Thread natalie.vanzuydam
Hi all, I realise that the convention is to provide a working example of my problem but the data are of a sensitive nature so I'm not able to do that in this case. I need to query a database for multiple search terms: db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1, 2