> Say I need to keep ID 1,2,4,5, 10 from the data frame dat. I can do: > dat <- data.frame(ID = 1:10, var = 1:10) > someID <- c(1,2,4,5,10) > subset(dat, dat$ID %in% someID) > Is there a quick way to do the opposite ... >
Two operators spring to mind: ! and %nin subset(dat, !(dat$ID %in% someID)) subset(dat, dat$ID %nin% someID) -- Curt Seeliger, Data Ranger Raytheon Information Services - Contractor to ORD [email protected] 541/754-4638 [[alternative HTML version deleted]] ______________________________________________ [email protected] 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.

