Skip to content
Prev 273508 / 398506 Next

Subsetting a data frame with multiple values and exclusions.

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     2    27  28.0
4 ind4     3     2   1.2

HTH,
Dennis
On Wed, Oct 5, 2011 at 8:53 AM, natalie.vanzuydam <nvanzuydam at gmail.com> wrote: